Hey Xiabo,
You can do this, however it is easiest to do from the "FrameworkConfig"
object, like this:
import org.apache.calcite.tools.FrameworkConfig
// Need to set case-sensitive to false, or else it tries to
// look up capitalized table names and fails
//
// IE: "EMPS" instead of "emps"
val frameworkConfig: FrameworkConfig = Frameworks.newConfigBuilder()
.defaultSchema(connection.rootSchema)
.parserConfig(SqlParser.config().withCaseSensitive(false))
.build()
Hope this helps =)
On Fri, Feb 11, 2022 at 9:09 PM xiaobo <[email protected]> wrote:
> sorry for the html escape characters,
> we tried the following and it does not work
>
> Class.forName("org.apache.calcite.jdbc.Driver");
> Properties info = new Properties();
> info.setProperty("lex", "JAVA");
> info.setProperty(InternalProperty.CASE_SENSITIVE.name(),
> "false");
> info.setProperty("defaultSchema", "hr");
> Connection connection =
> DriverManager.getConnection("jdbc:calcite:", info);
> CalciteConnection conn =
> connection.unwrap(CalciteConnection.class);
> SchemaPlus rootSchema = conn.getRootSchema();
> Schema schema = new ReflectiveSchema(target);
> rootSchema.add(schemaName, schema);
> return conn;
>
>
>
>
> ------------------ Original ------------------
> From: "xiaobo ";<[email protected]>;
> Send time: Friday, Feb 11, 2022 11:20 PM
> To: "dev"<[email protected]>;
>
> Subject: can we set a default schema for calcite connection to avoid
> writing schema names in sql
>
>
>
> we have tried the following and it does not work
>
>
> Class.forName("org.apache.calcite.jdbc.Driver");
> Properties info =
> new Properties();
>
> info.setProperty("lex", "JAVA");
>
> info.setProperty(CalciteConnectionProperty.CASE_SENSITIVE.camelName(),
> "false");
>
> info.setProperty("defaultSchema", "hr");
> try {
>
> Connection connection =
>
>
> DriverManager.getConnection("jdbc:calcite:", info);
>
> CalciteConnection conn =
>
>
> connection.unwrap(CalciteConnection.class);
>
> SchemaPlus rootSchema = conn.getRootSchema();
>