org.apache.calcite.avatica.Helper Java Examples

The following examples show how to use org.apache.calcite.avatica.Helper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CalciteConnectionImpl.java    From Quicksql with MIT License 6 votes vote down vote up
private CalcitePreparedStatement prepareStatement_(
    CalcitePrepare.Query<?> query,
    int resultSetType,
    int resultSetConcurrency,
    int resultSetHoldability) throws SQLException {
  try {
    final Meta.Signature signature =
        parseQuery(query, createPrepareContext(), -1);
    final CalcitePreparedStatement calcitePreparedStatement =
        (CalcitePreparedStatement) factory.newPreparedStatement(this, null,
            signature, resultSetType, resultSetConcurrency, resultSetHoldability);
    server.getStatement(calcitePreparedStatement.handle).setSignature(signature);
    return calcitePreparedStatement;
  } catch (Exception e) {
    throw Helper.INSTANCE.createException(
        "Error while preparing statement [" + query.sql + "]", e);
  }
}
 
Example #2
Source File: CalciteConnectionImpl.java    From calcite with Apache License 2.0 6 votes vote down vote up
private CalcitePreparedStatement prepareStatement_(
    CalcitePrepare.Query<?> query,
    int resultSetType,
    int resultSetConcurrency,
    int resultSetHoldability) throws SQLException {
  try {
    final Meta.Signature signature =
        parseQuery(query, createPrepareContext(), -1);
    final CalcitePreparedStatement calcitePreparedStatement =
        (CalcitePreparedStatement) factory.newPreparedStatement(this, null,
            signature, resultSetType, resultSetConcurrency, resultSetHoldability);
    server.getStatement(calcitePreparedStatement.handle).setSignature(signature);
    return calcitePreparedStatement;
  } catch (Exception e) {
    throw Helper.INSTANCE.createException(
        "Error while preparing statement [" + query.sql + "]", e);
  }
}
 
Example #3
Source File: EnumerableInterpretable.java    From Quicksql with MIT License 5 votes vote down vote up
public static Bindable toBindable(Map<String, Object> parameters,
    CalcitePrepare.SparkHandler spark, EnumerableRel rel,
    EnumerableRel.Prefer prefer) {
  EnumerableRelImplementor relImplementor =
      new EnumerableRelImplementor(rel.getCluster().getRexBuilder(),
          parameters);

  final ClassDeclaration expr = relImplementor.implementRoot(rel, prefer);
  String s = Expressions.toString(expr.memberDeclarations, "\n", false);

  if (CalciteSystemProperty.DEBUG.value()) {
    Util.debugCode(System.out, s);
  }

  Hook.JAVA_PLAN.run(s);

  try {
    if (spark != null && spark.enabled()) {
      return spark.compile(expr, s);
    } else {
      return getBindable(expr, s, rel.getRowType().getFieldCount());
    }
  } catch (Exception e) {
    throw Helper.INSTANCE.wrap("Error while compiling generated Java code:\n"
        + s, e);
  }
}
 
Example #4
Source File: HiveEnumerableInterpretable.java    From marble with Apache License 2.0 5 votes vote down vote up
public static Bindable toBindable(Map<String, Object> parameters,
    CalcitePrepare.SparkHandler spark, EnumerableRel rel,
    EnumerableRel.Prefer prefer) {
  HiveEnumerableRelImplementor relImplementor =
      new HiveEnumerableRelImplementor(rel.getCluster().getRexBuilder(),
          parameters);

  final ClassDeclaration expr = relImplementor.implementRoot(rel, prefer);
  String s = Expressions.toString(expr.memberDeclarations, "\n", false);

  if (CalcitePrepareImpl.DEBUG) {
    Util.debugCode(System.out, s);
  }

  Hook.JAVA_PLAN.run(s);

  try {
    if (spark != null && spark.enabled()) {
      return spark.compile(expr, s);
    } else {
      return getBindable(expr, s,
          rel.getRowType().getFieldCount());
    }
  } catch (Exception e) {
    throw Helper.INSTANCE.wrap("Error while compiling generated Java code:\n"
        + s, e);
  }
}
 
Example #5
Source File: EnumerableInterpretable.java    From calcite with Apache License 2.0 5 votes vote down vote up
public static Bindable toBindable(Map<String, Object> parameters,
    CalcitePrepare.SparkHandler spark, EnumerableRel rel,
    EnumerableRel.Prefer prefer) {
  EnumerableRelImplementor relImplementor =
      new EnumerableRelImplementor(rel.getCluster().getRexBuilder(),
          parameters);

  final ClassDeclaration expr = relImplementor.implementRoot(rel, prefer);
  String s = Expressions.toString(expr.memberDeclarations, "\n", false);

  if (CalciteSystemProperty.DEBUG.value()) {
    Util.debugCode(System.out, s);
  }

  Hook.JAVA_PLAN.run(s);

  try {
    if (spark != null && spark.enabled()) {
      return spark.compile(expr, s);
    } else {
      return getBindable(expr, s, rel.getRowType().getFieldCount());
    }
  } catch (Exception e) {
    throw Helper.INSTANCE.wrap("Error while compiling generated Java code:\n"
        + s, e);
  }
}