当前位置: 首页>>代码示例>>Java>>正文


Java SqlParserPos类代码示例

本文整理汇总了Java中org.apache.calcite.sql.parser.SqlParserPos的典型用法代码示例。如果您正苦于以下问题:Java SqlParserPos类的具体用法?Java SqlParserPos怎么用?Java SqlParserPos使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SqlParserPos类属于org.apache.calcite.sql.parser包,在下文中一共展示了SqlParserPos类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCalciteTypeWithNullability

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
private RelDataType createCalciteTypeWithNullability(RelDataTypeFactory typeFactory,
                                                     SqlTypeName sqlTypeName,
                                                     boolean isNullable) {
  RelDataType type;
  if (sqlTypeName == SqlTypeName.INTERVAL_DAY_TIME) {
    type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
            TimeUnit.DAY,
            TimeUnit.MINUTE,
            SqlParserPos.ZERO));
  } else if (sqlTypeName == SqlTypeName.INTERVAL_YEAR_MONTH) {
    type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
            TimeUnit.YEAR,
            TimeUnit.MONTH,
           SqlParserPos.ZERO));
  } else if (sqlTypeName == SqlTypeName.VARCHAR) {
    type = typeFactory.createSqlType(sqlTypeName, TypeHelper.VARCHAR_DEFAULT_CAST_LEN);
  } else {
    type = typeFactory.createSqlType(sqlTypeName);
  }
  return typeFactory.createTypeWithNullability(type, isNullable);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:DrillConstExecutor.java

示例2: rewrite

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的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);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:ShowSchemasHandler.java

示例3: FieldType

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
@JsonCreator
public FieldType(
    @JsonProperty("name")                       String name,
    @JsonProperty("type")                       SqlTypeName type,
    @JsonProperty("precision")                  Integer precision,
    @JsonProperty("scale")                      Integer scale,
    @JsonProperty("startUnit")                  TimeUnit startUnit,
    @JsonProperty("endUnit")                    TimeUnit endUnit,
    @JsonProperty("fractionalSecondPrecision")  Integer fractionalSecondPrecision,
    @JsonProperty("isNullable")                 Boolean isNullable) {
  this.name = name;
  this.type = type;
  this.precision = precision;
  this.scale = scale;
  this.intervalQualifier =
      null == startUnit
      ? null
      : new SqlIntervalQualifier(
          startUnit, precision, endUnit, fractionalSecondPrecision, SqlParserPos.ZERO );

  // Property "isNullable" is not part of the initial view definition and
  // was added in DRILL-2342.  If the default value is null, consider it as
  // "true".  It is safe to default to "nullable" than "required" type.
  this.isNullable = isNullable == null ? true : isNullable;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:26,代码来源:View.java

示例4: SqlCreateTable

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
public SqlCreateTable(
    SqlParserPos pos,
    SqlIdentifier tblName,
    SqlNodeList fieldList,
    PartitionDistributionStrategy partitionDistributionStrategy,
    SqlNodeList partitionColumns,
    SqlNodeList formatOptions,
    SqlLiteral singleWriter,
    SqlNode query,
    SqlNodeList sortFieldList,
    SqlNodeList distributionColumns) {
  super(pos);
  this.tblName = tblName;
  this.fieldList = fieldList;
  this.partitionDistributionStrategy = partitionDistributionStrategy;
  this.partitionColumns = partitionColumns;
  this.formatOptions = formatOptions;
  this.singleWriter = singleWriter;
  this.query = query;
  this.sortColumns = sortFieldList;
  this.distributionColumns = distributionColumns;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:SqlCreateTable.java

示例5: parseError

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
public static UserException.Builder parseError(String query, SqlParseException ex) {
  final SqlParserPos pos = ex.getPos();
  if (pos == null) {
    return UserException
        .parseError(ex)
        .addContext("SQL Query", query);
  } else {
    return UserException
        .parseError(ex)
        .addContext("SQL Query", query)
        .addContext("startLine", pos.getLineNum())
        .addContext("startColumn", pos.getColumnNum())
        .addContext("endLine", pos.getEndLineNum())
        .addContext("endColumn", pos.getEndColumnNum());
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:SqlExceptionHelper.java

示例6: formatSQLParsingError

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
/**
 *
 * @param sql
 *          the SQL sent to the server
 * @param pos
 *          the position of the error
 * @return The sql with a ^ character under the error
 */
static String formatSQLParsingError(String sql, SqlParserPos pos) {
  StringBuilder sb = new StringBuilder();
  String[] lines = sql.split("\n");
  for (int i = 0; i < lines.length; i++) {
    String line = lines[i];
    sb.append(line).append("\n");
    if (i == (pos.getLineNum() - 1)) {
      for (int j = 0; j < pos.getColumnNum() - 1; j++) {
        sb.append(" ");
      }
      sb.append("^\n");
    }
  }
  return sb.toString();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:24,代码来源:SqlConverter.java

示例7: testErrorFormating

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
@Test
public void testErrorFormating() {
  String sql = "Select * from Foo\nwhere tadadidada;\n";
  validateFormattedIs(sql, new SqlParserPos(1, 2),
      "Select * from Foo\n"
    + " ^\n"
    + "where tadadidada;\n");
  validateFormattedIs(sql, new SqlParserPos(2, 2),
      "Select * from Foo\n"
    + "where tadadidada;\n"
    + " ^\n" );
  validateFormattedIs(sql, new SqlParserPos(1, 10),
      "Select * from Foo\n"
    + "         ^\n"
    + "where tadadidada;\n");
  validateFormattedIs(sql, new SqlParserPos(-11, -10), sql);
  validateFormattedIs(sql, new SqlParserPos(0, 10), sql);
  validateFormattedIs(sql, new SqlParserPos(100, 10), sql);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:TestSQLConverter.java

示例8: SqlCreateFunction

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的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;
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:9,代码来源:SqlCreateFunction.java

示例9: makeOver

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
public RexNode makeOver(
		SqlAggFunction operator,
		List<RexNode> expressions,
		List<RexNode> partitionKeys
) {
	final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);

	// TODO
	// This is a temporal fix to make HAWQ work with OVER + UNLIMITED BOUNDS
	// HAWQ requires ORDER BY if andy BOUNDS are set even unlimited upper and lower BOUNDS (which is equal to
	// the entire partition - e.g. not setting BOUNDs at all --
	// Note that the unnecessary ORDER BY have negative performance impact and has to be remove once either HAWQ
	// start supporting unbounded bounds without order by or Calcite can generate shorthand OVER PARTITION BY
	// syntax.
	List<RexFieldCollation> orderKeys = expressions.stream().map(
			rexNode -> new RexFieldCollation(rexNode, flags)).collect(Collectors.toList());

	return makeOver(
			operator,
			expressions,
			partitionKeys,
			ImmutableList.copyOf(orderKeys),
			RexWindowBound.create(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO), null),
			RexWindowBound.create(SqlWindow.createUnboundedFollowing(SqlParserPos.ZERO), null),
			true,
			true,
			false
	);
}
 
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:30,代码来源:JdbcRelBuilder.java

示例10: setupMocks

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的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"));
}
 
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:36,代码来源:JournalledJdbcTableTest.java

示例11: createCondition

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
public static SqlNode createCondition(SqlNode left, SqlOperator op, SqlNode right) {

    // if one of the operands is null, return the other
    if (left == null || right == null) {
      return left != null ? left : right;
    }

    List<Object> listCondition = Lists.newArrayList();
    listCondition.add(left);
    listCondition.add(new SqlParserUtil.ToTreeListItem(op, SqlParserPos.ZERO));
    listCondition.add(right);

    return SqlParserUtil.toTree(listCondition);
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:15,代码来源:DrillParserUtil.java

示例12: SqlCreateView

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
public SqlCreateView(SqlParserPos pos, SqlIdentifier viewName, SqlNodeList fieldList,
                     SqlNode query, boolean replaceView) {
  super(pos);
  this.viewName = viewName;
  this.query = query;
  this.replaceView = replaceView;
  this.fieldList = fieldList;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:9,代码来源:SqlCreateView.java

示例13: getOperandList

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的package包/类
@Override
public List<SqlNode> getOperandList() {
  List<SqlNode> ops = Lists.newArrayList();
  ops.add(viewName);
  ops.add(fieldList);
  ops.add(query);
  ops.add(SqlLiteral.createBoolean(replaceView, SqlParserPos.ZERO));
  return ops;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:SqlCreateView.java

示例14: SqlTrainModel

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的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;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:SqlTrainModel.java

示例15: getAsCompoundIdentifier

import org.apache.calcite.sql.parser.SqlParserPos; //导入依赖的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);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:DrillCompoundIdentifier.java


注:本文中的org.apache.calcite.sql.parser.SqlParserPos类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。