clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

ResultSetMetaData#getTableName return same table when multi tables in the sql

Open Sochene opened this issue 4 years ago • 4 comments

        String sql = "select * from a,b"
        PreparedStatement preparedStatement = conn.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        ResultSetMetaData resultSetMetaData = preparedStatement.getMetaData();
        for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
            String bindTable = resultSetMetaData.getTableName(i);
        }

resultSetMetaData.getTableName(i) only return String "a"

Sochene avatar Oct 13 '22 13:10 Sochene

Thanks for the report @Sochene. ClickHouse does not provide enough metadata for a query, so the driver has to use SQL parser to extract table name, which apparently does not work for your case.

I thought about issuing an explain statement for each query, but it's probably not worthy due to it's poor performance.

Is this mandatory in your project? What's the user scenario?

zhicwu avatar Oct 14 '22 10:10 zhicwu

This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

github-actions[bot] avatar Jan 08 '25 00:01 github-actions[bot]

The 0.9.0 parse handles the SQL from example. The only left problem is to fix column's table name.

chernser avatar Jul 01 '25 06:07 chernser

Server doesn't return table information for a column. This is a technical limitation even when column is specified. It relates to RowBinary that is used to read data.

chernser avatar Sep 23 '25 06:09 chernser