/** Creates a {@link org.apache.calcite.rel.core.TableScan} of the table * with a given name. * * <p>Throws if the table does not exist. * * <p>Returns this builder. * * @param tableNames Name of table (can optionally be qualified) */ public HiveSubQRemoveRelBuilder scan(Iterable<String> tableNames) { final List<String> names = ImmutableList.copyOf(tableNames); final RelOptTable relOptTable = relOptSchema.getTableForMember(names); if (relOptTable == null) { throw Static.RESOURCE.tableNotFound(Joiner.on(".").join(names)).ex(); } final RelNode scan = scanFactory.createScan(cluster, relOptTable); push(scan); return this; }
/** Creates a call to an aggregate function. */ public AggCall aggregateCall(SqlAggFunction aggFunction, boolean distinct, RexNode filter, String alias, Iterable<? extends RexNode> operands) { if (filter != null) { if (filter.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) { throw Static.RESOURCE.filterMustBeBoolean().ex(); } if (filter.getType().isNullable()) { filter = call(SqlStdOperatorTable.IS_TRUE, filter); } } return new AggCallImpl(aggFunction, distinct, filter, alias, ImmutableList.copyOf(operands)); }
private static RuntimeException notArithmetic(String op, Object b0, Object b1) { return RESOURCE.invalidTypesForArithmetic(b0.getClass().toString(), op, b1.getClass().toString()).ex(); }
public T ex() { return ex(null); }
/** Creates a call to an aggregate function. */ public AggCall aggregateCall(SqlAggFunction aggFunction, boolean distinct, boolean approximate, RexNode filter, String alias, Iterable<? extends RexNode> operands) { if (filter != null) { if (filter.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) { throw RESOURCE.filterMustBeBoolean().ex(); } if (filter.getType().isNullable()) { filter = call(SqlStdOperatorTable.IS_TRUE, filter); } } return new AggCallImpl(aggFunction, distinct, approximate, filter, alias, ImmutableList.copyOf(operands)); }
/** Creates a {@code TableMacro} from a method. */ public static TableMacro create(final Method method) { Class clazz = method.getDeclaringClass(); if (!Modifier.isStatic(method.getModifiers())) { if (!classHasPublicZeroArgsConstructor(clazz)) { throw RESOURCE.requireDefaultConstructor(clazz.getName()).ex(); } } final Class<?> returnType = method.getReturnType(); if (!TranslatableTable.class.isAssignableFrom(returnType)) { return null; } return new TableMacroImpl(method); }
/** Creates a {@code TableMacro} from a method. */ public static TableMacro create(final Method method) { Class clazz = method.getDeclaringClass(); if (!Modifier.isStatic(method.getModifiers())) { if (!classHasPublicZeroArgsConstructor(clazz)) { throw RESOURCE.requireDefaultConstructor(clazz.getName()).ex(); } } final Class<?> returnType = method.getReturnType(); if (!TranslatableTable.class.isAssignableFrom(returnType)) { return null; } return new TableMacroImpl(method); }
public T ex() { return ex(null); }
public Exception call() throws Exception { return ex(); } });
@NonDeterministic private static Object cannotConvert(Object o, Class toType) { throw RESOURCE.cannotConvert(o.toString(), toType.toString()).ex(); }
/** Support the ELEMENT function. */ public static Object element(List list) { switch (list.size()) { case 0: return null; case 1: return list.get(0); default: throw RESOURCE.moreThanOneValueInList(list.toString()).ex(); } }
private static RuntimeException notComparable(String op, Object b0, Object b1) { return RESOURCE.invalidTypesForComparison(b0.getClass().toString(), op, b1.getClass().toString()).ex(); }
public static void jsonObjectAggAdd(Map map, String k, Object v, SqlJsonConstructorNullClause nullClause) { if (k == null) { throw RESOURCE.nullKeyOfJsonObjectNotAllowed().ex(); } if (v == null) { if (nullClause == SqlJsonConstructorNullClause.NULL_ON_NULL) { map.put(k, null); } } else { map.put(k, v); } }
public Exception call() throws Exception { return ex(); } });
public static PathContext withReturned(PathMode mode, Object pathReturned) { if (mode == PathMode.UNKNOWN) { throw RESOURCE.illegalJsonPathMode(mode.toString()).ex(); } if (mode == PathMode.STRICT && pathReturned == null) { throw RESOURCE.strictPathModeRequiresNonEmptyValue().ex(); } return new PathContext(mode, pathReturned, null); }
/** CAST(VARCHAR AS BOOLEAN). */ public static boolean toBoolean(String s) { s = trim(true, true, " ", s); if (s.equalsIgnoreCase("TRUE")) { return true; } else if (s.equalsIgnoreCase("FALSE")) { return false; } else { throw RESOURCE.invalidCharacterForCast(s).ex(); } }
/** * Checks to see whether cancellation has been requested, and if so, throws * an exception. */ public void checkCancel() { if (cancelFlag.get()) { throw RESOURCE.preparationAborted().ex(); } }
/** * Checks to see whether cancellation has been requested, and if so, throws * an exception. */ public void checkCancel() { if (cancelFlag.get()) { throw RESOURCE.preparationAborted().ex(); } }
/** Creates a {@link org.apache.calcite.rel.core.TableScan} of the table * with a given name. * * <p>Throws if the table does not exist. * * <p>Returns this builder. * * @param tableNames Name of table (can optionally be qualified) */ public HiveSubQRemoveRelBuilder scan(Iterable<String> tableNames) { final List<String> names = ImmutableList.copyOf(tableNames); final RelOptTable relOptTable = relOptSchema.getTableForMember(names); if (relOptTable == null) { throw Static.RESOURCE.tableNotFound(Joiner.on(".").join(names)).ex(); } final RelNode scan = scanFactory.createScan(cluster, relOptTable); push(scan); return this; }
/** Creates a call to an aggregate function. */ public AggCall aggregateCall(SqlAggFunction aggFunction, boolean distinct, RexNode filter, String alias, Iterable<? extends RexNode> operands) { if (filter != null) { if (filter.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) { throw Static.RESOURCE.filterMustBeBoolean().ex(); } if (filter.getType().isNullable()) { filter = call(SqlStdOperatorTable.IS_TRUE, filter); } } return new AggCallImpl(aggFunction, distinct, filter, alias, ImmutableList.copyOf(operands)); }