MGelbana commented on a change in pull request #1250: [CALCITE-3108] Babel
parser should parse the PostgreSQL TEXT type
URL: https://github.com/apache/calcite/pull/1250#discussion_r290965310
##########
File path: babel/src/main/codegen/config.fmpp
##########
@@ -833,6 +835,7 @@ data: {
# Return type of method implementation should be "SqlIdentifier".
# Example: SqlParseTimeStampZ().
dataTypeParserMethods: [
+ "PostgreSQLTypes"
Review comment:
Because the metadata for the returned resultset for that query using calcite
won't return `Foo` for the column type name, it will return whatever
`SqlTypeName` `Foo` was configured to act like (ex: `BIGINT`).
**Example:**
The following code prints `TEXT`
```java
Connection connection = // A connection to a real PostgreSQL DB
PreparedStatement statement = connection.prepareStatement("SELECT
column1::TEXT FROM (VALUES (1, 2, 3)) a");
System.out.println(statement.executeQuery().getMetaData().getColumnTypeName(1));
```
The following code prints `VARCHAR` (It should print `TEXT` instead)
```java
Connection connection = DriverManager.getConnection("jdbc:calcite:", info);
connection.unwrap(CalciteConnection.class).getRootSchema().unwrap(CalciteSchema.class).add("TEXT",
new RelProtoDataType() {
@Override
public RelDataType apply(RelDataTypeFactory factory) {
return
factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.VARCHAR),
false);
}
});
PreparedStatement statement = connection.prepareStatement("SELECT
CAST(EXPR$0 AS text) FROM (VALUES (1, 2, 3)) a");
System.out.println(statement.executeQuery().getMetaData().getColumnTypeName(1));
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services