-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-1358461: Issue with metadata query for columns #1746
Comments
Hello @jb-saurabh , Thanks for raising the question. Did you try setting the parameter CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX=true, this parameter can change the default search scope from all databases/schemas to the current database/schema. The narrower search typically returns fewer rows and executes more quickly. Documentation: let us know if you still facing the issue after setting below parameter. Example `stmt.execute("alter session set CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX = true"); DatabaseMetaData dbmd = con.getMetaData();
` Regards, |
Hi @sfc-gh-sghosh, |
Hello @jb-saurabh , Thanks for the update. I just tested it again, its perfectly narrow down to the current schema and database ( which is being used in the connection URL ) and will only search the respective table. If you pass the respective catalog and scehma, then it will search from that specific catalog and schema. if you do not pass any database or catalog, then its recommended to use the below parameter CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX . I am getting same output for both the case. Example: I am not passing the database or schema (its null) , I am passing only the tablename. stmt.execute("alter session set CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX = true"); ResultSet columns = dbmd.getColumns(null, null, "MYCSVTABLE", null); Output: Get columns Table name and size: MYCSVTABLE Catalog: SAMPLEDATABASE Table name and size: MYCSVTABLE Catalog: SAMPLEDATABASE So, please try again and let us know your code if still doesnt work. Regards, |
Hi @sfc-gh-sghosh, But my issue is when I am providing a schema name like TEST_SCHEMA and a table name like MY_CSVTABLE then it will load metadata for the complete database. And query will be become something like: show /* JDBC:DatabaseMetaData.getColumns() */ columns in database "SAMPLEDATABASE" Concludingly It should working as expected for dbmd.getColumns("SAMPLEDATABASE", "TEST_SCHEMA ", "MY_CSVTABLE ", null); |
@jb-saurabh That method supports pattern matching, but the |
@jb-saurabh have you tried escaping the underscore character and confirm that you get the expected output? |
Hi @sfc-gh-wfateem |
Thanks for confirming @jb-saurabh |
I am utilizing the
getColumns
method ofSnowflakeDatabaseMetaData
class. As I debug I found that internally it makes query:show /* JDBC:DatabaseMetaData.getColumns() */ columns in database "MY_DB_NAME"
,If my schema or table name includes underscore (_) like A_BC in the name because it checks for wildcard patterns internally, and if it finds any, it creates a query for the entire metadata instead of just the table.
like: If there is _ in Schema name
show /* JDBC:DatabaseMetaData.getColumns() */ columns in database " ABC_DATABASE"
Expecting:
If I am providing all details like Database, Schema, and Table name with or without underscore (_) like A_BC then it should create a query like:
show /* JDBC:DatabaseMetaData.getColumns() */ columns in table "MY_DB_NAME"."MY_SCHEMA_NAME"."MY_TABLE_NAME"
Library:
Responsible code:
I have also checked the recently released
version 3.16.0
but still happening the same. https://github.com/snowflakedb/snowflake-jdbc/blob/master/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java#L1674The text was updated successfully, but these errors were encountered: