[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17058102#comment-17058102 ] Julian Hyde commented on CALCITE-3716: -- [~zabetak] Yes. And add some comments explaining the difference in policy between Avatica & JDBC. > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug > Components: jdbc-driver >Affects Versions: 1.21.0 >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Fix For: 1.23.0 > > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17057758#comment-17057758 ] Stamatis Zampetakis commented on CALCITE-3716: -- [~julianhyde] I guess you mean in AvaticaResultSetMetaData. Indeed it seems like the best place to put this logic > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug > Components: jdbc-driver >Affects Versions: 1.21.0 >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Fix For: 1.23.0 > > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17057482#comment-17057482 ] Julian Hyde commented on CALCITE-3716: -- How about we do the 'right' thing in ColumnMetaData, which is for schemaName, catalogName and tableName to be null if the column has no underlying database column? Then translate those nulls to empty string in the JDBC methods. It seems to a similar situation to ordinal: JDBC mandates that ordinals are 1-based, but internally we use 0-based. > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug > Components: jdbc-driver >Affects Versions: 1.21.0 >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Fix For: 1.23.0 > > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17057444#comment-17057444 ] Stamatis Zampetakis commented on CALCITE-3716: -- I had a quick look in the PR and I was wondering if the fix would be more appropriate at the Avatica level and not in its clients (in this case Calcite). The ResultSetMetadata API explicitly says to return an empty string for the following methods: * getSchemaName * getCatalogName * getTableName For me this would mean that either the constructor of ColumnMetaData throws an exception when one of these values is null or automatically converts null to empty string for the methods above. I prefer the latter since with this approach apart from Calcite we may fix also other clients of Avatica. I am not pushing strongly about this I just wanted to hear your thoughts. > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug > Components: jdbc-driver >Affects Versions: 1.21.0 >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Fix For: 1.23.0 > > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17040639#comment-17040639 ] Danny Chen commented on CALCITE-3716: - Is this issue planning to be resolved in release 1.22 ? > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug > Components: jdbc-driver >Affects Versions: 1.21.0 >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Fix For: 1.22.0 > > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17033909#comment-17033909 ] Julian Hyde commented on CALCITE-3716: -- Yes, I agree that the MySQL behavior is superior, and I agree that Calcite is consistent with it. (In the above code, some of your '1's should be '2's. I changed them.) > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17030352#comment-17030352 ] Jin Xing commented on CALCITE-3716: --- Thanks a lot Julian ~ I also want mention that the behavior of getColumnName is different between Sql systems; When I have below table and run sql by JDBC connect: {code:java} Table: test (col0 int) select a x, 1 y from test{code} ColumnName and ColumnLabel returned as below: {code:java} Mysql: ResultSet#getMetadata().getColumnName(1): "a" ResultSet#getMetadata().getColumnLabel(1): "x" ResultSet#getMetadata().getColumnName(1): "y" ResultSet#getMetadata().getColumnLabel(1): "y" Postgre: ResultSet#getMetadata().getColumnName(1): "x" ResultSet#getMetadata().getColumnLabel(1): "x" ResultSet#getMetadata().getColumnName(1): "y" ResultSet#getMetadata().getColumnLabel(1): "y"{code} I didn't find which one is standard behavior from JDBC spec; Behavior of Calcite is consistent with Mysql; > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17029228#comment-17029228 ] Julian Hyde commented on CALCITE-3716: -- I reviewed the JDBC spec and I agree with you that {{getColumnName}} behaves differently than {{getTableName}}, {{getSchemaName}}, {{getCatalogName}}. (If I had written the JDBC spec I would have done it differently, to make it consistent with {{getTableName}}. But I didn't. Also, I wish they had spelled out what is supposed to happen "if not applicable".) So, let's continue to return the label, which may of course be null. If people want to know whether a result set field maps onto a DB column they should see whether {{getTableName}} returns empty string. > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17027285#comment-17027285 ] Jin Xing commented on CALCITE-3716: --- {color:#172b4d}Thanks a lot [~julianhyde] for review ~{color} * {color:#172b4d}I didn't find from {color}[JDBC spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getColumnName-int-]{color:#172b4d} specifies that {color}*columnName*{color:#172b4d} should be empty string rather than null.{color} * Constructor of ColumnMetaDatas[1] sets *columnName* by *label* if the param passed in is null. * I updated and replaced _assertEquals_ with _assertThat_ [1][https://github.com/apache/calcite-avatica/blob/dd65a2b18b8c35cfccf1c47b6be87ea7db3ad658/core/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java#L122] > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17025352#comment-17025352 ] Julian Hyde commented on CALCITE-3716: -- * Does {{getColumnName}} need to be fixed also? * Please use {{assertThat}} rather than {{assertEquals}}. (We don't use {{assertEquals}} because people tend to get the arguments the wrong way round, as you did.) > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CALCITE-3716) ResultSetMetaData.getTableName should return empty string, not null, when column does not map to a table
[ https://issues.apache.org/jira/browse/CALCITE-3716?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17025103#comment-17025103 ] Jin Xing commented on CALCITE-3716: --- Hi, Julian ~ I made a PR and try to fix this issue. Please take a look when you have time ~ > ResultSetMetaData.getTableName should return empty string, not null, when > column does not map to a table > > > Key: CALCITE-3716 > URL: https://issues.apache.org/jira/browse/CALCITE-3716 > Project: Calcite > Issue Type: Bug >Reporter: Julian Hyde >Assignee: Jin Xing >Priority: Major > Labels: pull-request-available > Time Spent: 50m > Remaining Estimate: 0h > > Per the [JDBC > spec|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getTableName-int-], > {{ResultSetMetaData.getTableName}} should return empty string, not null, > when column does not map to a table. Similarly getCatalogName, getSchemaName, > getColumnName. -- This message was sent by Atlassian Jira (v8.3.4#803005)