[ 
https://issues.apache.org/jira/browse/FLINK-31552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marios Trivyzas reassigned FLINK-31552:
---------------------------------------

    Assignee: Marios Trivyzas

> Cannot use schema other than public with TableEnvironment
> ---------------------------------------------------------
>
>                 Key: FLINK-31552
>                 URL: https://issues.apache.org/jira/browse/FLINK-31552
>             Project: Flink
>          Issue Type: Bug
>          Components: Connectors / JDBC
>            Reporter: Marios Trivyzas
>            Assignee: Marios Trivyzas
>            Priority: Major
>
> Cannot use a schema other than *public* in 
> TableEnvironment+flink-jdbc-connector.
> Postgres:
>  
> {noformat}
> psql (15.1)
> Type "help" for help.
> matriv=> create schema myschema;
> CREATE SCHEMA
> matriv=> create table myschema.t1(a int);
> CREATE TABLE
> matriv=> insert into myschema.t1(a) values (1), (2);
> INSERT 0 2
> matriv=> select * from myschema.t1;
>  a  
> ---
>  1
>  2
> (2 rows)
> {noformat}
> {noformat}
> EnvironmentSettings settings = 
> EnvironmentSettings.newInstance().inStreamingMode().build();
> TableEnvironment tableEnv = TableEnvironment.create(settings);
> String name            = "my_catalog";
> String defaultDatabase = "matriv";
> String username        = "matriv";
> String password        = "matriv";
> String baseUrl         = "jdbc:postgresql://localhost:5432";
> JdbcCatalog catalog = new JdbcCatalog(name, defaultDatabase, username, 
> password, baseUrl);
> tableEnv.registerCatalog("my_catalog", catalog);
> // set the JdbcCatalog as the current catalog of the session
> tableEnv.listTables();
> tableEnv.executeSql("select * from myschema.t1").print();{noformat}
> Exception:
> {noformat}
> Exception in thread "main" org.apache.flink.table.api.ValidationException: 
> SQL validation failed. From line 1, column 15 to line 1, column 25: Object 
> 'myschema' not found
>     at 
> org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:186)
>     at 
> org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:113)
>     at 
> org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:261)
>     at 
> org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:106)
>     at 
> org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:723)
>     at 
> io.crate.streaming.TaxiRidesStreamingJob.main(TaxiRidesStreamingJob.java:109)
> Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, 
> column 15 to line 1, column 25: Object 'myschema' not found
>     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>     at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, 
> column 15 to line 1, column 25: Object 'myschema' not found    at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>     at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:467)
>     at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:883)
>     at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:868)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4867)
>     at 
> org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:179)
>     at 
> org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:184)
>     at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:997)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:975)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3085)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3070)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3335)
>     at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>     at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:997)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:975)
>     at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:232)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:952)
>     at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:704)
>     at 
> org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:182)
>     ... 5 more
> {noformat}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to