Java Code Examples for org.apache.calcite.util.Bug#upgrade()

The following examples show how to use org.apache.calcite.util.Bug#upgrade() . 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: TpcdsTest.java    From calcite with Apache License 2.0 6 votes vote down vote up
private CalciteAssert.AssertQuery checkQuery(int i) {
  final Query query = Query.of(i);
  String sql = query.sql(new Random(0));
  switch (i) {
  case 58:
    if (Bug.upgrade("new TPC-DS generator")) {
      // Work around bug: Support '<DATE>  = <character literal>'.
      sql = sql.replace(" = '", " = DATE '");
    } else {
      // Until TPC-DS generator can handle date(...).
      sql = sql.replace("'date([YEAR]+\"-01-01\",[YEAR]+\"-07-24\",sales)'",
          "DATE '1998-08-18'");
    }
    break;
  case 72:
    // Work around CALCITE-304: Support '<DATE> + <INTEGER>'.
    sql = sql.replace("+ 5", "+ interval '5' day");
    break;
  case 95:
    sql = sql.replace("60 days", "interval '60' day");
    sql = sql.replace("d_date between '", "d_date between date '");
    break;
  }
  return with()
      .query(sql.replace("tpcds.", "tpcds_01."));
}
 
Example 2
Source File: SqlLineTest.java    From calcite with Apache License 2.0 6 votes vote down vote up
/**
 * Execute a script with "sqlline -f".
 *
 * @throws java.lang.Throwable On error
 * @return The stderr and stdout from running the script
 * @param args Script arguments
 */
private static Pair<SqlLine.Status, String> run(String... args)
    throws Throwable {
  SqlLine sqlline = new SqlLine();
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  PrintStream sqllineOutputStream =
      new PrintStream(os, false, StandardCharsets.UTF_8.name());
  sqlline.setOutputStream(sqllineOutputStream);
  sqlline.setErrorStream(sqllineOutputStream);
  SqlLine.Status status = SqlLine.Status.OK;

  Bug.upgrade("[sqlline-35] Make Sqlline.begin public");
  // TODO: status = sqlline.begin(args, null, false);

  return Pair.of(status, os.toString("UTF8"));
}
 
Example 3
Source File: DateRangeRules.java    From Bats with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
ExtractShuttle(RexBuilder rexBuilder, TimeUnitRange timeUnit, Map<RexNode, RangeSet<Calendar>> operandRanges,
        ImmutableSortedSet<TimeUnitRange> timeUnitRanges, String timeZone) {
    this.rexBuilder = Objects.requireNonNull(rexBuilder);
    this.timeUnit = Objects.requireNonNull(timeUnit);
    Bug.upgrade("Change type to Map<RexNode, RangeSet<Calendar>> when" + " [CALCITE-1367] is fixed");
    this.operandRanges = Objects.requireNonNull(operandRanges);
    this.timeUnitRanges = Objects.requireNonNull(timeUnitRanges);
    this.timeZone = timeZone;
}
 
Example 4
Source File: SubQueryDecorrelator.java    From flink with Apache License 2.0 4 votes vote down vote up
public TreeSet<CorRef> get() {
	Bug.upgrade("use MultimapBuilder when we're on Guava-16");
	return com.google.common.collect.Sets.newTreeSet();
}
 
Example 5
Source File: SubQueryDecorrelator.java    From flink with Apache License 2.0 4 votes vote down vote up
public TreeSet<CorRef> get() {
	Bug.upgrade("use MultimapBuilder when we're on Guava-16");
	return com.google.common.collect.Sets.newTreeSet();
}
 
Example 6
Source File: CassandraExtension.java    From calcite with Apache License 2.0 3 votes vote down vote up
/**
 * Whether to run this test.
 * <p>Enabled by default, unless explicitly disabled
 * from command line ({@code -Dcalcite.test.cassandra=false}) or running on incompatible JDK
 * version (see below).
 *
 * <p>As of this wiring Cassandra 4.x is not yet released and we're using 3.x
 * (which fails on JDK11+). All cassandra tests will be skipped if
 * running on JDK11+.
 *
 * @see <a href="https://issues.apache.org/jira/browse/CASSANDRA-9608">CASSANDRA-9608</a>
 * @return {@code true} if test is compatible with current environment,
 *         {@code false} otherwise
 */
@Override public ConditionEvaluationResult evaluateExecutionCondition(
    final ExtensionContext context) {
  boolean enabled = CalciteSystemProperty.TEST_CASSANDRA.value();
  Bug.upgrade("remove JDK version check once current adapter supports Cassandra 4.x");
  boolean compatibleJdk = TestUtil.getJavaMajorVersion() < 11;
  if (enabled && compatibleJdk) {
    return ConditionEvaluationResult.enabled("Cassandra enabled");
  }
  return ConditionEvaluationResult.disabled("Cassandra tests disabled");
}