impl(bq_driver): metadata descriptors for SQLPrimaryKeys and SQLForeignKeys#1292
impl(bq_driver): metadata descriptors for SQLPrimaryKeys and SQLForeignKeys#1292Anshu6250 wants to merge 6 commits into
Conversation
| // ODBCBQClient::GetAllQueryResults() to fetch all the results. In this case, | ||
| // the GetQueryResults will be populated in DSResults structure. | ||
| // | ||
| static std::map<std::string, ColumnSchema> const kODBCForeignKeysMap = { |
There was a problem hiding this comment.
Remove ODBC From variable name
| // ODBCBQClient::GetAllQueryResults() to fetch all the results. In this case, | ||
| // the GetQueryResults will be populated in DSResults structure. | ||
| // | ||
| static std::map<std::string, ColumnSchema> const kODBCPrimaryKeysMap = { |
There was a problem hiding this comment.
Remove ODBC from variable name
| type_info.col_size, | ||
| descriptor_record.precision); | ||
| auto const& col_name = res.name; | ||
| bool is_128_wvarchar_col = |
There was a problem hiding this comment.
please follow variable naming convection, remove numerical value from variable name.
| col_name == "PKTABLE_SCHEM" || col_name == "PKTABLE_NAME" || | ||
| col_name == "FKTABLE_SCHEM" || col_name == "FKTABLE_NAME"; | ||
|
|
||
| if (is_128_wvarchar_col || is_1024_wvarchar_col) { |
There was a problem hiding this comment.
| descriptor_record.local_type_name = "WVARCHAR"; | ||
| (void)descriptor_record.SetConciseType(SQL_WVARCHAR, | ||
| DescriptorType::kIRD); | ||
| descriptor_record.length = is_1024_wvarchar_col ? 1024 : 128; |
There was a problem hiding this comment.
| SQLSMALLINT col_count = 0; | ||
| ret = SQLNumResultCols(conn->hstmt, &col_count); | ||
| ASSERT_TRUE(SQL_SUCCEEDED(ret)); | ||
| std::cout << "num cols = " << col_count << std::endl; |
There was a problem hiding this comment.
remove this std::cout
| &data_type, &col_size, &decimal_digits, &nullable); | ||
| ASSERT_TRUE(SQL_SUCCEEDED(ret)); | ||
|
|
||
| std::cout << "Column " << i << ": Name='" << col_name |
There was a problem hiding this comment.
|
Remove all |
| } | ||
|
|
||
| TEST(StatementTest, Check_SQL_Primary_key) { | ||
| auto conn = std::make_shared<ODBCHandles>(); |
There was a problem hiding this comment.
these test cases will pass even on main branch as SQLNumResultCols is succedding even on main with column count as 0 and for loop won't be triggered, please modify them to check for explicit column count number
There was a problem hiding this comment.
test cases are now updated
039322c to
33b5851
Compare
| # Ignores this word globally across the project | ||
| [default.extend-words] |
There was a problem hiding this comment.
Revert this file changes.
There was a problem hiding this comment.
This change is necessary because the checkers were failing
| type_info.col_size, | ||
| descriptor_record.precision); | ||
| std::string const& col_name = res.name; | ||
|
|
There was a problem hiding this comment.
have you verified with simba? , each group taking same descriptor values
There was a problem hiding this comment.
yes i have verified
ba11869 to
3efe3f9
Compare
| } | ||
|
|
||
| TEST(StatementTest, Check_SQL_Primary_key) { | ||
| auto conn = std::make_shared<ODBCHandles>(); |
There was a problem hiding this comment.
see to combine the common functionality in both the test cases in one single function as can see a lot of common functionality including the ExpectedCol structure
86fe8df to
cf8da38
Compare
cf8da38 to
47d13cf
Compare
47d13cf to
48e7f73
Compare
| {"TABLE_SCHEM", ColumnSchema{1, BQDataType::kString}}, | ||
| {"TABLE_NAME", ColumnSchema{2, BQDataType::kString}}, | ||
| {"COLUMN_NAME", ColumnSchema{3, BQDataType::kString}}, | ||
| {"KEY_SEQ", ColumnSchema{4, BQDataType::kInt64}}, |
There was a problem hiding this comment.
You can probably add KEY_SEQ and PK_NAME to kODBCColumnsMap.
Please see if code duplication can be avoided in other places as well.
There was a problem hiding this comment.
hi @sachinpro
Yes, I’ve updated this. I introduced a common schema containing shared metadata columns like TABLE_CAT, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, KEY_SEQ, and PK_NAME, and reused it to avoid duplication.
24256da to
6daa6d9
Compare
This PR adds metadata descriptors for SQLPrimaryKeys and SQLForeignKeys, similar to what we already do for SQLTables and SQLColumns.