本文整理汇总了Java中org.apache.calcite.sql.SqlIdentifier类的典型用法代码示例。如果您正苦于以下问题:Java SqlIdentifier类的具体用法?Java SqlIdentifier怎么用?Java SqlIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SqlIdentifier类属于org.apache.calcite.sql包,在下文中一共展示了SqlIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toResult
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
@Override
public List<SimpleCommandResult> toResult(String sql, SqlNode sqlNode) throws Exception {
final SqlAddLayout addLayout = SqlNodeUtil.unwrap(sqlNode, SqlAddLayout.class);
final TableWithPath table = SchemaUtilities.verify(defaultSchema, addLayout.getTblName());
SqlIdentifier identifier = addLayout.getName();
String name = null;
if(identifier != null) {
name = identifier.toString();
} else {
name = "Unnamed-" + ThreadLocalRandom.current().nextLong();
}
final LayoutDefinition layout = new LayoutDefinition(name,
addLayout.isRaw() ? LayoutDefinition.Type.RAW : LayoutDefinition.Type.AGGREGATE,
table.qualifyColumns(addLayout.getDisplayList()),
table.qualifyColumnsWithGranularity(addLayout.getDimensionList()),
table.qualifyColumns(addLayout.getMeasureList()),
table.qualifyColumns(addLayout.getSortList()),
table.qualifyColumns(addLayout.getDistributionList()),
table.qualifyColumns(addLayout.getPartitionList()),
addLayout.getPartitionDistributionStrategy()
);
accel.addLayout(table.getPath(), layout);
return Collections.singletonList(SimpleCommandResult.successful("Layout added."));
}
示例2: rewrite
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
/** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.SCHEMATA ... */
@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
SqlShowSchemas node = unwrap(sqlNode, SqlShowSchemas.class);
List<SqlNode> selectList =
ImmutableList.of((SqlNode) new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO));
SqlNode fromClause = new SqlIdentifier(
ImmutableList.of(IS_SCHEMA_NAME, TAB_SCHEMATA), null, SqlParserPos.ZERO, null);
SqlNode where = null;
final SqlNode likePattern = node.getLikePattern();
if (likePattern != null) {
where = DrillParserUtil.createCondition(new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO),
SqlStdOperatorTable.LIKE, likePattern);
} else if (node.getWhereClause() != null) {
where = node.getWhereClause();
}
return new SqlSelect(SqlParserPos.ZERO, null, new SqlNodeList(selectList, SqlParserPos.ZERO),
fromClause, where, null, null, null, null, null, null);
}
示例3: getPlan
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
/**
* Function resolves the schema and invokes the drop method. Raises an exception if the schema is
* immutable.
* @param sqlNode - Table name identifier
* @return - Single row indicating drop succeeded, raise exception otherwise
* @throws ValidationException
* @throws RelConversionException
* @throws IOException
*/
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
SqlDropTable dropTableNode = ((SqlDropTable) sqlNode);
SqlIdentifier tableIdentifier = dropTableNode.getTableIdentifier();
SchemaPlus defaultSchema = context.getNewDefaultSchema();
AbstractSchema drillSchema = null;
if (tableIdentifier != null) {
drillSchema = SchemaUtilites.resolveToMutableDrillSchema(defaultSchema, dropTableNode.getSchema());
}
String tableName = ((SqlDropTable) sqlNode).getName();
if (drillSchema == null) {
throw UserException.validationError()
.message("Invalid table_name [%s]", tableName)
.build(logger);
}
drillSchema.dropTable(tableName);
return DirectPlan.createDirectPlan(context, true,
String.format("Table [%s] %s", tableName, "dropped"));
}
示例4: lookupOperatorOverloads
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
@Override
public void lookupOperatorOverloads(SqlIdentifier opName, SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList) {
if (syntax == SqlSyntax.FUNCTION) {
// add optiq.
inner.lookupOperatorOverloads(opName, category, syntax, operatorList);
if(!operatorList.isEmpty()){
return;
}
List<SqlOperator> drillOps = opMap.get(opName.getSimple().toLowerCase());
if(drillOps != null){
operatorList.addAll(drillOps);
}
} else {
inner.lookupOperatorOverloads(opName, category, syntax, operatorList);
}
}
示例5: getParentsFromSql
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
/**
* Return lists of {@link ParentDatasetInfo} from given list of directly referred tables in the query.
* @return The list of directly referenced virtual or physical datasets
*/
private List<ParentDatasetInfo> getParentsFromSql(List<SqlIdentifier> ancestors) {
if (ancestors == null) {
return null;
}
try {
final List<ParentDatasetInfo> result = new ArrayList<>();
for (SqlIdentifier sqlIdentifier : ancestors) {
final NamespaceKey datasetPath = new NamespaceKey(sqlIdentifier.names);
result.add(getDataset(datasetPath));
}
return result;
} catch (RuntimeException e) {
logger.warn(
"Failure while attempting to extract parents from dataset. This is likely due to "
+ "a datasource no longer being available that was used in a past job.", e);
return Collections.emptyList();
}
}
示例6: QueryMetadata
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
public QueryMetadata(List<SqlIdentifier> ancestors,
List<FieldOrigin> fieldOrigins, List<JoinInfo> joins, List<ParentDatasetInfo> parents,
SqlNode sqlNode, RelDataType rowType,
List<ParentDataset> grandParents, final RelOptCost cost, final PlanningSet planningSet,
final RelNode serializableLogicalPlan,
BatchSchema batchSchema) {
this.rowType = rowType;
this.ancestors = Optional.fromNullable(ancestors);
this.fieldOrigins = Optional.fromNullable(fieldOrigins);
this.joins = Optional.fromNullable(joins);
this.parents = Optional.fromNullable(parents);
this.sqlNode = Optional.fromNullable(sqlNode);
this.grandParents = Optional.fromNullable(grandParents);
this.cost = Optional.fromNullable(cost);
this.planningSet = Optional.fromNullable(planningSet);
this.serializableLogicalPlan = Optional.fromNullable(serializableLogicalPlan);
this.batchSchema = batchSchema;
}
示例7: extractAS
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
private static ASNode extractAS(SqlCall call) {
if (call.getOperator().getKind() == SqlKind.AS) {
List<SqlNode> operandList = call.getOperandList();
if (operandList.size() == 2) {
SqlNode exp = operandList.get(0);
SqlNode colID = operandList.get(1);
if (isSimpleID(colID)) {
return new ASNode((SqlIdentifier)colID, exp);
} else {
throw new UnsupportedOperationException("Unexpected AS " + colID + "\n" + SqlNodes.toTreeString(call));
}
} else {
throw new UnsupportedOperationException("Unexpected AS operands in field: \n" + SqlNodes.toTreeString(call));
}
}
throw new UnsupportedOperationException("AS not understood: " + SqlNodes.toSQLString(call));
}
示例8: SqlCreateFunction
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
public SqlCreateFunction(SqlParserPos pos, SqlIdentifier dbName,
SqlIdentifier funcName, SqlNode className, SqlNodeList jarList) {
super(pos);
this.dbName = dbName;
this.funcName = funcName;
this.className = className;
this.jarList = jarList;
}
示例9: setupMocks
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
@Before
@SuppressWarnings("ResultOfMethodCallIgnored") // Mockito syntax
public void setupMocks() {
relBuilder = Mockito.mock(JdbcRelBuilder.class);
journalTable = Mockito.mock(JdbcTable.class);
relOptTable = Mockito.mock(RelOptTable.class);
context = Mockito.mock(RelOptTable.ToRelContext.class);
JdbcRelBuilderFactory relBuilderFactory = Mockito.mock(JdbcRelBuilderFactory.class);
RelOptCluster relOptCluster = Mockito.mock(RelOptCluster.class);
JournalledJdbcSchema schema = Mockito.mock(JournalledJdbcSchema.class);
RelOptSchema relOptSchema = Mockito.mock(RelOptSchema.class);
RexInputRef versionField = Mockito.mock(RexInputRef.class);
RexInputRef subsequentVersionField = Mockito.mock(RexInputRef.class);
Mockito.doReturn(Schema.TableType.TABLE).when(journalTable).getJdbcTableType();
table = new JournalledJdbcTable("theView", schema, journalTable, new String[] {"key1", "key2"});
table.relBuilderFactory = relBuilderFactory;
Mockito.doReturn("myV").when(schema).getVersionField();
Mockito.doReturn("mySV").when(schema).getSubsequentVersionField();
Mockito.doReturn(relOptCluster).when(context).getCluster();
Mockito.doReturn(relBuilder).when(relBuilderFactory).create(Mockito.same(relOptCluster), Mockito.same(relOptSchema));
Mockito.doReturn(Mockito.mock(RelOptPlanner.class)).when(relOptCluster).getPlanner();
Mockito.doReturn(relOptSchema).when(relOptTable).getRelOptSchema();
Mockito.doReturn(ImmutableList.of("theSchema", "theView")).when(relOptTable).getQualifiedName();
Mockito.doReturn(new SqlIdentifier(
ImmutableList.of("wrongSchema", "theJournal"),
null,
new SqlParserPos(0, 0),
null
)).when(journalTable).tableName();
Mockito.doReturn(versionField).when(relBuilder).field(Mockito.eq("myV"));
Mockito.doReturn(subsequentVersionField).when(relBuilder).field(Mockito.eq("mySV"));
}
示例10: idToRef
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
private static String idToRef(FromNode from, SqlIdentifier id) {
if (isSimpleID(id)) {
// TODO: need to check if quotes are correct
return id.getSimple();
} else {
SqlIdentifier finalId = id;
// removing unnecessary table prefix from col ref.
if (id.names.size() > from.alias.names.size()) {
boolean isPrefix = true;
for (int i = 0; i < from.alias.names.size(); i++) {
String an = from.alias.names.get(i);
String idn = id.names.get(i);
if (!an.equals(idn)) {
isPrefix = false;
break;
}
}
if (isPrefix) {
finalId = id.getComponent(from.alias.names.size(), id.names.size());
}
}
if (!finalId.isSimple()) {
throw new IllegalArgumentException("expected a simple type column name (directly or prefixed with table name/alias)");
}
return finalId.getSimple();
}
}
示例11: visit
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
@Override
public SqlNode visit(SqlIdentifier id) {
if(id instanceof DrillCompoundIdentifier){
if(enableComplex){
return ((DrillCompoundIdentifier) id).getAsSqlNode();
}else{
return ((DrillCompoundIdentifier) id).getAsCompoundIdentifier();
}
}else{
return id;
}
}
示例12: extractFrom
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
private FromNode extractFrom(SqlSelect select) {
SqlNode from = select.getFrom();
return from.accept(new BaseSqlVisitor<FromNode>() {
@Override
public FromNode visit(SqlIdentifier id) {
return new FromNode(null, id);
}
@Override
public FromNode visit(SqlCall call) {
SqlOperator operator = call.getOperator();
switch (operator.getKind()) {
case AS:
ASNode as = extractAS(call);
if (as.exp.getKind() == IDENTIFIER) {
SqlIdentifier ref = (SqlIdentifier)as.exp;
if (!as.alias.isSimple()) {
throw new UnsupportedOperationException("Table aliasing not supported:\n" + SqlNodes.toTreeString(call));
}
return new FromNode(as.alias, ref);
} else {
throw new UnsupportedOperationException("Unexpected AS:\n" + SqlNodes.toTreeString(call));
}
default:
throw new UnsupportedOperationException("Unexpected operator in call: " + operator.getKind() + "\n" + SqlNodes.toTreeString(call));
}
}
});
}
示例13: SqlTrainModel
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
public SqlTrainModel(SqlParserPos pos, SqlIdentifier mdlName, SqlNodeList fieldList, SqlNodeList partitionColumns, SqlNode query) {
super(pos);
this.mdlName = mdlName;
this.fieldList = fieldList;
this.partitionColumns = partitionColumns;
this.query = query;
}
示例14: getAsCompoundIdentifier
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
public SqlNode getAsCompoundIdentifier(){
List<String> names = Lists.newArrayListWithCapacity(ids.size());
List<SqlParserPos> pos = Lists.newArrayListWithCapacity(ids.size());
for(int i =0; i < ids.size(); i++){
IdentifierHolder holder = ids.get(i);
names.add(holder.value);
pos.add(holder.parserPos);
}
return new SqlIdentifier(names, null, pos.get(0), pos);
}
示例15: SqlCreateTable
import org.apache.calcite.sql.SqlIdentifier; //导入依赖的package包/类
public SqlCreateTable(SqlParserPos pos, SqlIdentifier tblName, SqlNodeList fieldList, SqlNodeList partitionColumns, SqlNode query) {
super(pos);
this.tblName = tblName;
this.fieldList = fieldList;
this.partitionColumns = partitionColumns;
this.query = query;
}