Skip to content
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-1250205: Driver returns incorrect column type while querying on Query History Views #1676

Closed
inishchith opened this issue Mar 19, 2024 · 4 comments
Assignees
Labels
status-information_needed Additional information is required from the reporter status-triage_done Initial triage done, will be further handled by the driver team

Comments

@inishchith
Copy link

inishchith commented Mar 19, 2024

  1. What version of JDBC driver are you using?
  1. What operating system and processor architecture are you using?
  • MacOS Ventura 13.6.4, arm64
  1. What version of Java are you using?
  • Java 18
  1. What did you do?
  • Views in Context - Access History, Query History
    • The document suggests that the column QUERY_START_TIME (from Access History View) and START_TIME (from Query History View) are both of type TIMESTAMP_LTZ.
  • Via the JDBC driver, try to fetch the row for the same query (via query_id)

example query:

SELECT 
    qh.QUERY_ID AS QHI, 
    qh.START_TIME AS START_TIME, 
    ah.QUERY_ID AS AHI, 
    ah.QUERY_START_TIME AS QUERY_START_TIME 
FROM 
    SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY AS qh
INNER JOIN 
    SNOWFLAKE.ACCOUNT_USAGE.ACCESS_HISTORY AS ah 
ON 
    qh.QUERY_ID = ah.QUERY_ID
WHERE 
    qh.QUERY_ID='QUERY_ID';
  1. What did you expect to see?
  • Both START_TIME and QUERY_START_TIME should ideally return the same column type (i.e TIMESTAMP_LTZ or SnowflakeTimestampWithTimezone) and value, but it doesn't. (image)

Screenshot 2024-03-18 at 8 31 59 PM

  1. Can you set logging to DEBUG and collect the logs?

    https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors

  2. What is your Snowflake account identifier, if any? (Optional)

  • qia75894
@inishchith inishchith added the bug label Mar 19, 2024
@github-actions github-actions bot changed the title Driver returns incorrect column type while querying on Query History Views SNOW-1250205: Driver returns incorrect column type while querying on Query History Views Mar 19, 2024
@sfc-gh-sghosh sfc-gh-sghosh self-assigned this Mar 20, 2024
@sfc-gh-sghosh sfc-gh-sghosh added status-triage Issue is under initial triage and removed bug labels Mar 20, 2024
@sfc-gh-sghosh
Copy link
Contributor

Hello @inishchith ,

Thanks for raising the issue, we are taking a look.

Regards,
Sujan

@sfc-gh-sghosh
Copy link
Contributor

Hello @inishchith ,

I tried to reproduce it with latest Snowflake JDBC 3.15.0, but its reflecting the correct data type TIMESTAMPLTZ for columns START_TIME from view SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY and SNOWFLAKE.ACCOUNT_USAGE.ACCESS_HISTORY

Here is the output:
Column Name: QHI, Data Type: VARCHAR
Column Name: START_TIME, Data Type: TIMESTAMPLTZ
Column Name: AHI, Data Type: VARCHAR
Column Name: QUERY_START_TIME, Data Type: TIMESTAMPLTZ

Here is the sample code snippet

ResultSet resultSet=statement.executeQuery("SELECT \n"
				+ "    qh.QUERY_ID AS QHI, \n"
				+ "    qh.START_TIME AS START_TIME, \n"
				+ "    ah.QUERY_ID AS AHI, \n"
				+ "    ah.QUERY_START_TIME AS QUERY_START_TIME \n"
				+ "FROM \n"
				+ "    SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY AS qh\n"
				+ "INNER JOIN \n"
				+ "    SNOWFLAKE.ACCOUNT_USAGE.ACCESS_HISTORY AS ah \n"
				+ "ON \n"
				+ "    qh.QUERY_ID = ah.QUERY_ID\n"
				+ "WHERE \n"
				+ "    qh.QUERY_ID='QUERY_ID' limit 1");
		

        ResultSetMetaData metaData = resultSet.getMetaData();
        int columnCount = metaData.getColumnCount();

   
        for (int i = 1; i <= columnCount; i++) {
            String columnName = metaData.getColumnName(i);
            String columnType = metaData.getColumnTypeName(i);
            System.out.println("Column Name: " + columnName + ", Data Type: " + columnType );

        }

Regards,
Sujaan

@sfc-gh-sghosh sfc-gh-sghosh added status-triage_done Initial triage done, will be further handled by the driver team and removed status-triage Issue is under initial triage labels Mar 27, 2024
@sfc-gh-sghosh
Copy link
Contributor

Hello @inishchith ,

let us know if anything further or if you could provide the sample application with jdbc log which reproduces the issue, because its working expected and no issue being surfaced.

Regards,
Sujan

@sfc-gh-sghosh sfc-gh-sghosh added the status-information_needed Additional information is required from the reporter label Apr 3, 2024
@inishchith
Copy link
Author

@sfc-gh-sghosh Thanks for the turnaround, I wasn't able to reproduce this with the above snippet.
I think this could be with the way I am using it - I shall take a look. We can close this, If am able to get back - will reopen and share.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status-information_needed Additional information is required from the reporter status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

2 participants