public class CalciteHelper extends Object
Constructor and Description |
---|
CalciteHelper(DataSource dataSource)
Initialize the helper with a datasource and it's schema.
|
Modifier and Type | Method and Description |
---|---|
static org.apache.calcite.tools.RelBuilder |
getBuilder(DataSource dataSource,
String schemaName)
Creates a
RelBuilder with the given schema. |
Connection |
getConnection()
Creates a connection to the database from the
dataSource . |
org.apache.calcite.tools.RelBuilder |
getNewRelBuilder(String schemaName)
Creates a
RelBuilder which can be used to build sql. |
org.apache.calcite.rel.rel2sql.RelToSqlConverter |
getNewRelToSqlConverter()
Creates a new
RelToSqlConverter using the dialect from
the datasource this was constructed with. |
org.apache.calcite.sql.pretty.SqlPrettyWriter |
getNewSqlWriter()
Creates a new
SqlPrettyWriter using the dialect from the
datasource this was constructed with. |
public CalciteHelper(DataSource dataSource) throws SQLException
dataSource
- The datasource to make connections with.SQLException
- if failed while making a connection to the database.public org.apache.calcite.tools.RelBuilder getNewRelBuilder(String schemaName)
RelBuilder
which can be used to build sql.schemaName
- The name of the schema that the tables are on.RelBuilder
or null if an error occurred.public Connection getConnection() throws SQLException
dataSource
.SQLException
- if can't create a connection.public org.apache.calcite.rel.rel2sql.RelToSqlConverter getNewRelToSqlConverter()
RelToSqlConverter
using the dialect from
the datasource this was constructed with.public org.apache.calcite.sql.pretty.SqlPrettyWriter getNewSqlWriter()
SqlPrettyWriter
using the dialect from the
datasource this was constructed with.public static org.apache.calcite.tools.RelBuilder getBuilder(DataSource dataSource, String schemaName) throws SQLException
RelBuilder
with the given schema.dataSource
- The dataSource for the jdbc schema.schemaName
- The name of the schema used for the database.SQLException
- if can't readSqlResultSet from database.Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.