本文整理汇总了Java中org.apache.calcite.util.Util类的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Util类属于org.apache.calcite.util包,在下文中一共展示了Util类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getWriter
import org.apache.calcite.util.Util; //导入依赖的package包/类
private Writer getWriter(OptionManager options, SchemaConfig.SchemaInfoProvider infoProvider) throws IOException{
final String storeTablePath = options.getOption(QUERY_RESULTS_STORE_TABLE.getOptionName()).string_val;
final List<String> storeTable = new StrTokenizer(storeTablePath, '.', ParserConfig.QUOTING.string.charAt(0))
.setIgnoreEmptyTokens(true).getTokenList();
// store query results as the system user
final SchemaPlus systemUserSchema = context.getRootSchema(
SchemaConfig
.newBuilder(SystemUser.SYSTEM_USERNAME)
.setProvider(infoProvider)
.build());
final AbstractSchema schema = SchemaUtilities.resolveToMutableSchemaInstance(systemUserSchema,
Util.skipLast(storeTable), true, MutationType.TABLE);
// Query results are stored in arrow format. If need arises, we can change
// this to a configuration option.
final Map<String, Object> storageOptions = ImmutableMap.<String, Object> of("type",
ArrowFormatPlugin.ARROW_DEFAULT_NAME);
final CreateTableEntry createTableEntry = schema.createNewTable(Util.last(storeTable), WriterOptions.DEFAULT, storageOptions);
return createTableEntry.getWriter(null);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:DirectWriterCommand.java
示例2: explainTerms
import org.apache.calcite.util.Util; //导入依赖的package包/类
public RelWriter explainTerms(RelWriter pw) {
// We skip the "groups" element if it is a singleton of "group".
pw.item("group", groupSet)
.itemIf("window", windowFn, windowFn != null)
.itemIf("trigger", trigger, trigger != null)
.itemIf("event_time", windowFieldIdx, windowFieldIdx != -1)
.itemIf("groups", groupSets, getGroupType() != Group.SIMPLE)
.itemIf("indicator", indicator, indicator)
.itemIf("aggs", aggCalls, pw.nest());
if (!pw.nest()) {
for (Ord<AggregateCall> ord : Ord.zip(aggCalls)) {
pw.item(Util.first(ord.e.name, "agg#" + ord.i), ord.e);
}
}
return pw;
}
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:BeamAggregationRel.java
示例3: containsInOperator
import org.apache.calcite.util.Util; //导入依赖的package包/类
/**
* Returns whether a given node contains a {@link SqlInOperator}.
*
* @param node a RexNode tree
*/
private static boolean containsInOperator(
SqlNode node) {
try {
SqlVisitor<Void> visitor =
new SqlBasicVisitor<Void>() {
public Void visit(SqlCall call) {
if (call.getOperator() instanceof SqlInOperator) {
throw new Util.FoundOne(call);
}
return super.visit(call);
}
};
node.accept(visitor);
return false;
} catch (Util.FoundOne e) {
Util.swallow(e, null);
return true;
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:SqlToRelConverter.java
示例4: convertJoinType
import org.apache.calcite.util.Util; //导入依赖的package包/类
private static JoinRelType convertJoinType(JoinType joinType) {
switch (joinType) {
case COMMA:
case INNER:
case CROSS:
return JoinRelType.INNER;
case FULL:
return JoinRelType.FULL;
case LEFT:
return JoinRelType.LEFT;
case RIGHT:
return JoinRelType.RIGHT;
default:
throw Util.unexpected(joinType);
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:SqlToRelConverter.java
示例5: convertSetOp
import org.apache.calcite.util.Util; //导入依赖的package包/类
/**
* Converts a set operation (UNION, INTERSECT, MINUS) into relational
* expressions.
*
* @param call Call to set operator
* @return Relational expression
*/
protected RelNode convertSetOp(SqlCall call) {
final RelNode left =
convertQueryRecursive(call.operand(0), false, null).project();
final RelNode right =
convertQueryRecursive(call.operand(1), false, null).project();
switch (call.getKind()) {
case UNION:
return LogicalUnion.create(ImmutableList.of(left, right), all(call));
case INTERSECT:
return LogicalIntersect.create(ImmutableList.of(left, right), all(call));
case EXCEPT:
return LogicalMinus.create(ImmutableList.of(left, right), all(call));
default:
throw Util.unexpected(call.getKind());
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:SqlToRelConverter.java
示例6: isValidSchema
import org.apache.calcite.util.Util; //导入依赖的package包/类
/**
* check if the schema provided is a valid schema:
* <li>schema is not indicated (only one element in the names list)<li/>
*
* @param names list of schema and table names, table name is always the last element
* @return throws a userexception if the schema is not valid.
*/
private void isValidSchema(final List<String> names) throws UserException {
SchemaPlus defaultSchema = session.getDefaultSchema(this.rootSchema);
String defaultSchemaCombinedPath = SchemaUtilites.getSchemaPath(defaultSchema);
List<String> schemaPath = Util.skipLast(names);
String schemaPathCombined = SchemaUtilites.getSchemaPath(schemaPath);
String commonPrefix = SchemaUtilites.getPrefixSchemaPath(defaultSchemaCombinedPath,
schemaPathCombined,
parserConfig.caseSensitive());
boolean isPrefixDefaultPath = commonPrefix.length() == defaultSchemaCombinedPath.length();
List<String> fullSchemaPath = Strings.isNullOrEmpty(defaultSchemaCombinedPath) ? schemaPath :
isPrefixDefaultPath ? schemaPath : ListUtils.union(SchemaUtilites.getSchemaPathAsList(defaultSchema), schemaPath);
if (names.size() > 1 && (SchemaUtilites.findSchema(this.rootSchema, fullSchemaPath) == null &&
SchemaUtilites.findSchema(this.rootSchema, schemaPath) == null)) {
SchemaUtilites.throwSchemaNotFoundException(defaultSchema, schemaPath);
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:24,代码来源:SqlConverter.java
示例7: executeSQL
import org.apache.calcite.util.Util; //导入依赖的package包/类
/**
* This is the main method takes SQL statement as input and contructs a DAG using contructs registered with this
* {@link SQLExecEnvironment}.
*
* @param sql SQL statement that should be converted to a DAG.
*/
public void executeSQL(DAG dag, String sql)
{
FrameworkConfig config = buildFrameWorkConfig();
Planner planner = Frameworks.getPlanner(config);
try {
logger.info("Parsing SQL statement: {}", sql);
SqlNode parsedTree = planner.parse(sql);
SqlNode validatedTree = planner.validate(parsedTree);
RelNode relationalTree = planner.rel(validatedTree).rel;
logger.info("RelNode relationalTree generate from SQL statement is:\n {}",
Util.toLinux(RelOptUtil.toString(relationalTree)));
RelNodeVisitor visitor = new RelNodeVisitor(dag, typeFactory);
visitor.traverse(relationalTree);
} catch (Exception e) {
throw Throwables.propagate(e);
} finally {
planner.close();
}
}
开发者ID:apache,项目名称:apex-malhar,代码行数:26,代码来源:SQLExecEnvironment.java
示例8: schemas
import org.apache.calcite.util.Util; //导入依赖的package包/类
Enumerable<MetaSchema> schemas(String catalog) {
return Linq4j.asEnumerable(
getConnection().getCalciteRootSchema().getSubSchemaMap().values())
.select(
new Function1<CalciteSchema, MetaSchema>() {
public MetaSchema apply(CalciteSchema calciteSchema) {
return new CalciteMetaSchema(
calciteSchema,
connection.getCatalog(),
calciteSchema.getName());
}
})
.orderBy(
new Function1<MetaSchema, Comparable>() {
public Comparable apply(MetaSchema metaSchema) {
return (Comparable) FlatLists.of(
Util.first(metaSchema.tableCatalog, ""),
metaSchema.tableSchem);
}
});
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:CalciteMetaImpl.java
示例9: containsInOperator
import org.apache.calcite.util.Util; //导入依赖的package包/类
/**
* Returns whether a given node contains a {@link SqlInOperator}.
*
* @param node a RexNode tree
*/
private static boolean containsInOperator(
SqlNode node) {
try {
SqlVisitor<Void> visitor =
new SqlBasicVisitor<Void>() {
public Void visit(SqlCall call) {
if (call.getOperator() instanceof SqlInOperator) {
throw new Util.FoundOne(call);
}
return super.visit(call);
}
};
node.accept(visitor);
return false;
} catch (Util.FoundOne e) {
Util.swallow(e, null);
return true;
}
}
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:SqlToRelConverter.java
示例10: convertJoinType
import org.apache.calcite.util.Util; //导入依赖的package包/类
private static JoinRelType convertJoinType(JoinType joinType) {
switch (joinType) {
case COMMA:
case INNER:
case CROSS:
return JoinRelType.INNER;
case FULL:
return JoinRelType.FULL;
case LEFT:
return JoinRelType.LEFT;
case RIGHT:
return JoinRelType.RIGHT;
default:
throw Util.unexpected(joinType);
}
}
开发者ID:apache,项目名称:kylin,代码行数:17,代码来源:SqlToRelConverter.java
示例11: convertSetOp
import org.apache.calcite.util.Util; //导入依赖的package包/类
/**
* Converts a set operation (UNION, INTERSECT, MINUS) into relational
* expressions.
*
* @param call Call to set operator
* @return Relational expression
*/
protected RelNode convertSetOp(SqlCall call) {
final RelNode left =
convertQueryRecursive(call.operand(0), false, null).project();
final RelNode right =
convertQueryRecursive(call.operand(1), false, null).project();
switch (call.getKind()) {
case UNION:
return LogicalUnion.create(ImmutableList.of(left, right), all(call));
case INTERSECT:
return LogicalIntersect.create(ImmutableList.of(left, right), all(call));
case EXCEPT:
return LogicalMinus.create(ImmutableList.of(left, right), all(call));
default:
throw Util.unexpected(call.getKind());
}
}
开发者ID:apache,项目名称:kylin,代码行数:27,代码来源:SqlToRelConverter.java
示例12: getAlias
import org.apache.calcite.util.Util; //导入依赖的package包/类
/**
* Derives an alias for a node, and invents a mangled identifier if it
* cannot.
*
* <p>Examples:
*
* <ul>
* <li>Alias: "1 + 2 as foo" yields "foo"
* <li>Identifier: "foo.bar.baz" yields "baz"
* <li>Anything else yields "expr$<i>ordinal</i>"
* </ul>
*
* @return An alias, if one can be derived; or a synthetic alias
* "expr$<i>ordinal</i>" if ordinal < 0; otherwise null
*/
public static String getAlias(SqlNode node, int ordinal) {
switch (node.getKind()) {
case AS:
// E.g. "1 + 2 as foo" --> "foo"
return ((SqlCall) node).operand(1).toString();
case OVER:
// E.g. "bids over w" --> "bids"
return getAlias(((SqlCall) node).operand(0), ordinal);
case IDENTIFIER:
// E.g. "foo.bar" --> "bar"
return Util.last(((SqlIdentifier) node).names);
default:
if (ordinal < 0) {
return null;
} else {
return SqlUtil.deriveAliasFromOrdinal(ordinal);
}
}
}
开发者ID:apache,项目名称:calcite,代码行数:38,代码来源:SqlValidatorUtil.java
示例13: rewriteRel
import org.apache.calcite.util.Util; //导入依赖的package包/类
public void rewriteRel(LogicalCorrelate rel) {
ImmutableBitSet.Builder newPos = ImmutableBitSet.builder();
for (int pos : rel.getRequiredColumns()) {
RelDataType corrFieldType =
rel.getLeft().getRowType().getFieldList().get(pos)
.getType();
if (corrFieldType.isStruct()) {
throw Util.needToImplement("correlation on structured type");
}
newPos.set(getNewForOldInput(pos));
}
LogicalCorrelate newRel =
LogicalCorrelate.create(getNewForOldRel(rel.getLeft()),
getNewForOldRel(rel.getRight()),
rel.getCorrelationId(),
newPos.build(),
rel.getJoinType());
setNewForOldRel(rel, newRel);
}
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:RelStructuredTypeFlattener.java
示例14: collect
import org.apache.calcite.util.Util; //导入依赖的package包/类
private static void collect(List<String> result, ResultSet resultSet)
throws SQLException {
final StringBuilder buf = new StringBuilder();
while (resultSet.next()) {
buf.setLength(0);
int n = resultSet.getMetaData().getColumnCount();
String sep = "";
for (int i = 1; i <= n; i++) {
buf.append(sep)
.append(resultSet.getMetaData().getColumnLabel(i))
.append("=")
.append(resultSet.getString(i));
sep = "; ";
}
result.add(Util.toLinux(buf.toString()));
}
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlTest.java
示例15: onMatch
import org.apache.calcite.util.Util; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final Aggregate aggregate = call.rel(0);
final DruidQuery query = call.rel(1);
if (!DruidQuery.isValidSignature(query.signature() + 'a')) {
return;
}
if (aggregate.indicator
|| aggregate.getGroupSets().size() != 1
|| BAD_AGG.apply(ImmutableTriple.of(aggregate, (RelNode) aggregate, query))
|| !validAggregate(aggregate, query)) {
return;
}
final RelNode newAggregate = aggregate.copy(aggregate.getTraitSet(),
ImmutableList.of(Util.last(query.rels)));
call.transformTo(DruidQuery.extendQuery(query, newAggregate));
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:DruidRules.java
示例16: unwrap
import org.apache.calcite.util.Util; //导入依赖的package包/类
public <T> T unwrap(Class<T> clazz) {
if (clazz.isInstance(this)) {
return clazz.cast(this);
}
if (clazz.isInstance(table)) {
return clazz.cast(table);
}
if (table instanceof Wrapper) {
final T t = ((Wrapper) table).unwrap(clazz);
if (t != null) {
return t;
}
}
if (clazz == CalciteSchema.class) {
return clazz.cast(
Schemas.subSchema(((CalciteCatalogReader) schema).rootSchema,
Util.skipLast(getQualifiedName())));
}
return null;
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:RelOptTableImpl.java
示例17: containsInputRef
import org.apache.calcite.util.Util; //导入依赖的package包/类
/**
* Returns whether a given tree contains any {link RexInputRef} nodes.
*
* @param node a RexNode tree
*/
public static boolean containsInputRef(
RexNode node) {
try {
RexVisitor<Void> visitor =
new RexVisitorImpl<Void>(true) {
public Void visitInputRef(RexInputRef inputRef) {
throw new Util.FoundOne(inputRef);
}
};
node.accept(visitor);
return false;
} catch (Util.FoundOne e) {
Util.swallow(e, null);
return true;
}
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:RexUtil.java
示例18: constructOperandList
import org.apache.calcite.util.Util; //导入依赖的package包/类
protected List<SqlNode> constructOperandList(
SqlValidator validator,
SqlCall call,
List<String> argNames) {
if (argNames == null) {
return call.getOperandList();
}
if (argNames.size() < call.getOperandList().size()) {
throw validator.newValidationError(call,
RESOURCE.someButNotAllArgumentsAreNamed());
}
final int duplicate = Util.firstDuplicate(argNames);
if (duplicate >= 0) {
throw validator.newValidationError(call,
RESOURCE.duplicateArgumentName(argNames.get(duplicate)));
}
final ImmutableList.Builder<SqlNode> argBuilder = ImmutableList.builder();
for (SqlNode operand : call.getOperandList()) {
if (operand.getKind() == SqlKind.ARGUMENT_ASSIGNMENT) {
final List<SqlNode> operandList = ((SqlCall) operand).getOperandList();
argBuilder.add(operandList.get(0));
}
}
return argBuilder.build();
}
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:SqlOperator.java
示例19: navigationInMeasure
import org.apache.calcite.util.Util; //导入依赖的package包/类
private SqlNode navigationInMeasure(SqlNode node, boolean allRows) {
final Set<String> prefix = node.accept(new PatternValidator(true));
Util.discard(prefix);
final List<SqlNode> ops = ((SqlCall) node).getOperandList();
final SqlOperator defaultOp =
allRows ? SqlStdOperatorTable.RUNNING : SqlStdOperatorTable.FINAL;
final SqlNode op0 = ops.get(0);
if (!isRunningOrFinal(op0.getKind())
|| !allRows && op0.getKind() == SqlKind.RUNNING) {
SqlNode newNode = defaultOp.createCall(SqlParserPos.ZERO, op0);
node = SqlStdOperatorTable.AS.createCall(SqlParserPos.ZERO, newNode, ops.get(1));
}
node = new NavigationExpander().go(node);
return node;
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlValidatorImpl.java
示例20: findOperatorCall
import org.apache.calcite.util.Util; //导入依赖的package包/类
/**
* Returns whether a given node contains a RexCall with a specified operator
*
* @param operator Operator to look for
* @param node a RexNode tree
*/
public static RexCall findOperatorCall(
final SqlOperator operator,
RexNode node) {
try {
RexVisitor<Void> visitor =
new RexVisitorImpl<Void>(true) {
public Void visitCall(RexCall call) {
if (call.getOperator().equals(operator)) {
throw new Util.FoundOne(call);
}
return super.visitCall(call);
}
};
node.accept(visitor);
return null;
} catch (Util.FoundOne e) {
Util.swallow(e, null);
return (RexCall) e.getNode();
}
}
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:RexUtil.java
注:本文中的org.apache.calcite.util.Util类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论