Skip to content

Commit

Permalink
fix lint and flakey test
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroshade committed Oct 16, 2024
1 parent 6dcd338 commit 9458848
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion c/driver/snowflake/snowflake_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class SnowflakeQuirks : public adbc_validation::DriverQuirks {
case NANOARROW_TYPE_LARGE_STRING:
case NANOARROW_TYPE_LIST:
case NANOARROW_TYPE_LARGE_LIST:
return NANOARROW_TYPE_STRING;
return NANOARROW_TYPE_STRING;
default:
return ingest_type;
}
Expand Down
27 changes: 14 additions & 13 deletions c/validation/adbc_validation_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ void ConnectionTest::TestMetadataGetObjectsTablesTypes() {
db_schemas_index <
ArrowArrayViewListChildOffset(catalog_db_schemas_list, row + 1);
db_schemas_index++) {

// db_schema_tables should either be null or an empty list
for (int64_t tables_index =
ArrowArrayViewListChildOffset(db_schema_tables_list, db_schemas_index);
Expand Down Expand Up @@ -743,13 +742,12 @@ void ConnectionTest::TestMetadataGetObjectsColumns() {

struct TestCase {
std::optional<std::string> filter;
std::vector<std::string> column_names;
std::vector<int32_t> ordinal_positions;
std::vector<std::pair<std::string, int32_t>> columns;
};

std::vector<TestCase> test_cases;
test_cases.push_back({std::nullopt, {"int64s", "strings"}, {1, 2}});
test_cases.push_back({"in%", {"int64s"}, {1}});
test_cases.push_back({std::nullopt, {{"int64s", 1}, {"strings", 2}}});
test_cases.push_back({"in%", {{"int64s", 1}}});

const std::string catalog = quirks()->catalog();

Expand All @@ -759,13 +757,14 @@ void ConnectionTest::TestMetadataGetObjectsColumns() {
SCOPED_TRACE(scope);

StreamReader reader;
std::vector<std::pair<std::string, int32_t>> columns;
std::vector<std::string> column_names;
std::vector<int32_t> ordinal_positions;

ASSERT_THAT(
AdbcConnectionGetObjects(
&connection, ADBC_OBJECT_DEPTH_COLUMNS, catalog.c_str(), nullptr, nullptr, nullptr,
test_case.filter.has_value() ? test_case.filter->c_str() : nullptr,
&connection, ADBC_OBJECT_DEPTH_COLUMNS, catalog.c_str(), nullptr, nullptr,
nullptr, test_case.filter.has_value() ? test_case.filter->c_str() : nullptr,
&reader.stream.value, &error),
IsOkStatus(&error));
ASSERT_NO_FATAL_FAILURE(reader.GetSchema());
Expand Down Expand Up @@ -835,10 +834,9 @@ void ConnectionTest::TestMetadataGetObjectsColumns() {
std::string temp(name.data, name.size_bytes);
std::transform(temp.begin(), temp.end(), temp.begin(),
[](unsigned char c) { return std::tolower(c); });
column_names.push_back(std::move(temp));
ordinal_positions.push_back(
static_cast<int32_t>(ArrowArrayViewGetIntUnsafe(
table_columns->children[1], columns_index)));
columns.emplace_back(std::move(temp),
static_cast<int32_t>(ArrowArrayViewGetIntUnsafe(
table_columns->children[1], columns_index)));
}
}
}
Expand All @@ -848,8 +846,11 @@ void ConnectionTest::TestMetadataGetObjectsColumns() {
} while (reader.array->release);

ASSERT_TRUE(found_expected_table) << "Did (not) find table in metadata";
ASSERT_EQ(test_case.column_names, column_names);
ASSERT_EQ(test_case.ordinal_positions, ordinal_positions);
// metadata columns do not guarantee the order they are returned in, we can
// avoid the test being flakey by sorting the column names we found
std::sort(columns.begin(), columns.end(),
[](const auto& a, const auto& b) -> bool { return a.first < b.first; });
ASSERT_EQ(test_case.columns, columns);
}
}

Expand Down

0 comments on commit 9458848

Please # to comment.