Search in sources :

Example 1 with CalcitePrepare

use of org.apache.calcite.jdbc.CalcitePrepare in project calcite by apache.

the class Schemas method prepare.

/**
 * Prepares a SQL query for execution. For use within Calcite only.
 */
public static CalcitePrepare.CalciteSignature<Object> prepare(final CalciteConnection connection, final CalciteSchema schema, final List<String> schemaPath, final String sql, final ImmutableMap<CalciteConnectionProperty, String> map) {
    final CalcitePrepare prepare = CalcitePrepare.DEFAULT_FACTORY.apply();
    final CalcitePrepare.Context context = makeContext(connection, schema, schemaPath, null, map);
    CalcitePrepare.Dummy.push(context);
    try {
        return prepare.prepareSql(context, CalcitePrepare.Query.of(sql), Object[].class, -1);
    } finally {
        CalcitePrepare.Dummy.pop(context);
    }
}
Also used : CalcitePrepare(org.apache.calcite.jdbc.CalcitePrepare)

Example 2 with CalcitePrepare

use of org.apache.calcite.jdbc.CalcitePrepare in project calcite by apache.

the class Schemas method parse.

/**
 * Parses and validates a SQL query. For use within Calcite only.
 */
public static CalcitePrepare.ParseResult parse(final CalciteConnection connection, final CalciteSchema schema, final List<String> schemaPath, final String sql) {
    final CalcitePrepare prepare = CalcitePrepare.DEFAULT_FACTORY.apply();
    final ImmutableMap<CalciteConnectionProperty, String> propValues = ImmutableMap.of();
    final CalcitePrepare.Context context = makeContext(connection, schema, schemaPath, null, propValues);
    CalcitePrepare.Dummy.push(context);
    try {
        return prepare.parse(context, sql);
    } finally {
        CalcitePrepare.Dummy.pop(context);
    }
}
Also used : CalcitePrepare(org.apache.calcite.jdbc.CalcitePrepare) CalciteConnectionProperty(org.apache.calcite.config.CalciteConnectionProperty)

Example 3 with CalcitePrepare

use of org.apache.calcite.jdbc.CalcitePrepare in project calcite by apache.

the class Schemas method convert.

/**
 * Parses and validates a SQL query and converts to relational algebra. For
 * use within Calcite only.
 */
public static CalcitePrepare.ConvertResult convert(final CalciteConnection connection, final CalciteSchema schema, final List<String> schemaPath, final String sql) {
    final CalcitePrepare prepare = CalcitePrepare.DEFAULT_FACTORY.apply();
    final ImmutableMap<CalciteConnectionProperty, String> propValues = ImmutableMap.of();
    final CalcitePrepare.Context context = makeContext(connection, schema, schemaPath, null, propValues);
    CalcitePrepare.Dummy.push(context);
    try {
        return prepare.convert(context, sql);
    } finally {
        CalcitePrepare.Dummy.pop(context);
    }
}
Also used : CalcitePrepare(org.apache.calcite.jdbc.CalcitePrepare) CalciteConnectionProperty(org.apache.calcite.config.CalciteConnectionProperty)

Example 4 with CalcitePrepare

use of org.apache.calcite.jdbc.CalcitePrepare in project calcite by apache.

the class Schemas method analyzeView.

/**
 * Analyzes a view. For use within Calcite only.
 */
public static CalcitePrepare.AnalyzeViewResult analyzeView(final CalciteConnection connection, final CalciteSchema schema, final List<String> schemaPath, final String viewSql, List<String> viewPath, boolean fail) {
    final CalcitePrepare prepare = CalcitePrepare.DEFAULT_FACTORY.apply();
    final ImmutableMap<CalciteConnectionProperty, String> propValues = ImmutableMap.of();
    final CalcitePrepare.Context context = makeContext(connection, schema, schemaPath, viewPath, propValues);
    CalcitePrepare.Dummy.push(context);
    try {
        return prepare.analyzeView(context, viewSql, fail);
    } finally {
        CalcitePrepare.Dummy.pop(context);
    }
}
Also used : CalcitePrepare(org.apache.calcite.jdbc.CalcitePrepare) CalciteConnectionProperty(org.apache.calcite.config.CalciteConnectionProperty)

Aggregations

CalcitePrepare (org.apache.calcite.jdbc.CalcitePrepare)4 CalciteConnectionProperty (org.apache.calcite.config.CalciteConnectionProperty)3