本文整理汇总了Java中org.apache.calcite.sql.SqlLiteral.createCharString方法的典型用法代码示例。如果您正苦于以下问题:Java SqlLiteral.createCharString方法的具体用法?Java SqlLiteral.createCharString怎么用?Java SqlLiteral.createCharString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.sql.SqlLiteral
的用法示例。
在下文中一共展示了SqlLiteral.createCharString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNode
import org.apache.calcite.sql.SqlLiteral; //导入方法依赖的package包/类
public SqlNode getNode(SqlNode node){
SqlLiteral literal;
if(isArray){
literal = SqlLiteral.createExactNumeric(value, parserPos);
}else{
literal = SqlLiteral.createCharString(value, parserPos);
}
return new SqlBasicCall(SqlStdOperatorTable.ITEM, new SqlNode[]{ node, literal }, parserPos);
}
示例2: getNode
import org.apache.calcite.sql.SqlLiteral; //导入方法依赖的package包/类
public static SqlNode getNode(SqlParserPos pos, Map<String, String> fieldMap, String queryString) {
SqlNode[] operands = new SqlNode[fieldMap.size() + 1];
for (String field : fieldMap.keySet()) {
int index = Integer.parseInt(fieldMap.get(field).substring(1));
operands[index] = getIdentifier(field);
}
SqlNode query = SqlLiteral.createCharString(queryString, pos);
operands[operands.length - 1] = query;
return new SqlBasicCall(OPERATOR, operands, pos);
}
示例3: visit
import org.apache.calcite.sql.SqlLiteral; //导入方法依赖的package包/类
@Override public SqlNode visit(SqlIdentifier id) {
// First check for builtin functions which don't have
// parentheses, like "LOCALTIME".
SqlCall call =
SqlUtil.makeCall(
validator.getOperatorTable(),
id);
if (call != null) {
return call.accept(this);
}
final SqlIdentifier fqId = getScope().fullyQualify(id).identifier;
SqlNode expandedExpr = fqId;
// Convert a column ref into ITEM(*, 'col_name').
// select col_name from (select * from dynTable)
// SqlIdentifier "col_name" would be resolved to a dynamic star field in dynTable's rowType.
// Expand such SqlIdentifier to ITEM operator.
if (DynamicRecordType.isDynamicStarColName(Util.last(fqId.names))
&& !DynamicRecordType.isDynamicStarColName(Util.last(id.names))) {
SqlNode[] inputs = new SqlNode[2];
inputs[0] = fqId;
inputs[1] = SqlLiteral.createCharString(
Util.last(id.names),
id.getParserPosition());
SqlBasicCall item_call = new SqlBasicCall(
SqlStdOperatorTable.ITEM,
inputs,
id.getParserPosition());
expandedExpr = item_call;
}
validator.setOriginal(expandedExpr, id);
return expandedExpr;
}
示例4: literal
import org.apache.calcite.sql.SqlLiteral; //导入方法依赖的package包/类
private SqlNode literal(RelDataType type, Object value) {
if (value == null) {
int precision = type.getPrecision();
int scale = type.getScale();
if (!type.getSqlTypeName().allowsPrec()) {
precision = -1;
}
if (!type.getSqlTypeName().allowsScale()) {
scale = -1;
}
return SqlStdOperatorTable.CAST.createCall(
SqlParserPos.ZERO,
SqlLiteral.createNull(SqlParserPos.ZERO),
new SqlDataTypeSpec(
new SqlIdentifier(type.getSqlTypeName().getName(),
SqlParserPos.ZERO), precision, scale, null, null,
SqlParserPos.ZERO));
}
switch (type.getSqlTypeName()) {
case BOOLEAN:
return SqlLiteral.createBoolean((Boolean) value, SqlParserPos.ZERO);
case TINYINT:
case SMALLINT:
case INTEGER:
case BIGINT:
return SqlLiteral.createExactNumeric(
value.toString(), SqlParserPos.ZERO);
case CHAR:
case VARCHAR:
return SqlLiteral.createCharString(value.toString(), SqlParserPos.ZERO);
case TIMESTAMP:
TimestampString ts = TimestampString.fromMillisSinceEpoch((Long) value);
return SqlLiteral.createTimestamp(ts, type.getPrecision(),
SqlParserPos.ZERO);
default:
throw new AssertionError(type);
}
}
示例5: createGroupExpr
import org.apache.calcite.sql.SqlLiteral; //导入方法依赖的package包/类
SqlNode createGroupExpr() {
// TODO: create an expression that could have no other source
return SqlLiteral.createCharString("xyz" + groupCount++,
SqlParserPos.ZERO);
}
示例6: convertLiteral
import org.apache.calcite.sql.SqlLiteral; //导入方法依赖的package包/类
public SqlNode convertLiteral(RexLiteral literal) {
// Numeric
if (SqlTypeFamily.EXACT_NUMERIC.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createExactNumeric(
literal.getValue().toString(),
SqlParserPos.ZERO);
}
if (SqlTypeFamily.APPROXIMATE_NUMERIC.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createApproxNumeric(
literal.getValue().toString(),
SqlParserPos.ZERO);
}
// Timestamp
if (SqlTypeFamily.TIMESTAMP.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createTimestamp(
literal.getValueAs(TimestampString.class),
0,
SqlParserPos.ZERO);
}
// Date
if (SqlTypeFamily.DATE.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createDate(
literal.getValueAs(DateString.class),
SqlParserPos.ZERO);
}
// Time
if (SqlTypeFamily.TIME.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createTime(
literal.getValueAs(TimeString.class),
0,
SqlParserPos.ZERO);
}
// String
if (SqlTypeFamily.CHARACTER.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createCharString(
((NlsString) (literal.getValue())).getValue(),
SqlParserPos.ZERO);
}
// Boolean
if (SqlTypeFamily.BOOLEAN.getTypeNames().contains(
literal.getTypeName())) {
return SqlLiteral.createBoolean(
(Boolean) literal.getValue(),
SqlParserPos.ZERO);
}
return null;
}
示例7: replaceTimeUnitOperand
import org.apache.calcite.sql.SqlLiteral; //导入方法依赖的package包/类
/**
* Copies a {@link SqlCall}, replacing the time unit operand with the given
* literal.
*
* @param call Call
* @param literal Literal to replace time unit with
* @param pos Parser position
* @return Modified call
*/
public static SqlCall replaceTimeUnitOperand(SqlCall call, String literal, SqlParserPos pos) {
SqlLiteral literalNode = SqlLiteral.createCharString(literal, null, pos);
return call.getOperator().createCall(call.getFunctionQuantifier(), pos,
call.getOperandList().get(0), literalNode);
}