本文整理汇总了Java中org.apache.calcite.sql.fun.SqlStdOperatorTable.ITEM属性的典型用法代码示例。如果您正苦于以下问题:Java SqlStdOperatorTable.ITEM属性的具体用法?Java SqlStdOperatorTable.ITEM怎么用?Java SqlStdOperatorTable.ITEM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.calcite.sql.fun.SqlStdOperatorTable
的用法示例。
在下文中一共展示了SqlStdOperatorTable.ITEM属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitCall
@Override
public Boolean visitCall(RexCall call) {
if (call.getOperator() == SqlStdOperatorTable.ITEM) {
final RexNode op0 = call.getOperands().get(0);
final RexNode op1 = call.getOperands().get(1);
if (op0 instanceof RexInputRef &&
op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
return true;
} else if (op0 instanceof RexCall &&
op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
return op0.accept(this);
}
}
return false;
}
示例2: isItem
/**
* Returns 'string' if it is a call to item['string'], null otherwise.
*/
static String isItem(RexCall call) {
if (call.getOperator() != SqlStdOperatorTable.ITEM) {
return null;
}
final RexNode op0 = call.getOperands().get(0);
final RexNode op1 = call.getOperands().get(1);
if (op0 instanceof RexInputRef
&& ((RexInputRef) op0).getIndex() == 0
&& op1 instanceof RexLiteral
&& ((RexLiteral) op1).getValue2() instanceof String) {
return (String) ((RexLiteral) op1).getValue2();
}
return null;
}
示例3: visitCall
@Override public String visitCall(RexCall call) {
final String name = isItem(call);
if (name != null) {
return "\"" + name + "\"";
}
final List<String> strings = visitList(call.operands);
if (call.getKind() == SqlKind.CAST) {
return strings.get(0).startsWith("$") ? strings.get(0).substring(1) : strings.get(0);
}
if (call.getOperator() == SqlStdOperatorTable.ITEM) {
final RexNode op1 = call.getOperands().get(1);
if (op1 instanceof RexLiteral && op1.getType().getSqlTypeName() == SqlTypeName.INTEGER) {
return stripQuotes(strings.get(0)) + "[" + ((RexLiteral) op1).getValue2() + "]";
}
}
throw new IllegalArgumentException("Translation of " + call.toString()
+ "is not supported by ElasticsearchProject");
}
示例4: getNode
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);
}
示例5: visitCall
@Override
public RexNode visitCall(RexCall call) {
final boolean isItem = call.getOperator().getSyntax() == SqlSyntax.SPECIAL && call.getOperator() == SqlStdOperatorTable.ITEM;
if(isItem){
return visitCandidate(call);
}
return super.visitCall(call);
}
示例6: isItem
/** Returns 'string' if it is a call to item['string'], null otherwise. */
static String isItem(RexCall call) {
if (call.getOperator() != SqlStdOperatorTable.ITEM) {
return null;
}
final RexNode op0 = call.operands.get(0);
final RexNode op1 = call.operands.get(1);
if (op0 instanceof RexInputRef
&& ((RexInputRef) op0).getIndex() == 0
&& op1 instanceof RexLiteral
&& ((RexLiteral) op1).getValue2() instanceof String) {
return (String) ((RexLiteral) op1).getValue2();
}
return null;
}
示例7: visit
@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;
}
示例8: visitCall
@Override public String visitCall(RexCall call) {
String name = isItem(call);
if (name != null) {
return "'$" + name + "'";
}
final List<String> strings = visitList(call.operands);
if (call.getKind() == SqlKind.CAST) {
return strings.get(0);
}
String stdOperator = MONGO_OPERATORS.get(call.getOperator());
if (stdOperator != null) {
return "{" + stdOperator + ": [" + Util.commaList(strings) + "]}";
}
if (call.getOperator() == SqlStdOperatorTable.ITEM) {
final RexNode op1 = call.operands.get(1);
if (op1 instanceof RexLiteral
&& op1.getType().getSqlTypeName() == SqlTypeName.INTEGER) {
if (!Bug.CALCITE_194_FIXED) {
return "'" + stripQuotes(strings.get(0)) + "["
+ ((RexLiteral) op1).getValue2() + "]'";
}
return strings.get(0) + "[" + strings.get(1) + "]";
}
}
if (call.getOperator() == SqlStdOperatorTable.CASE) {
StringBuilder sb = new StringBuilder();
StringBuilder finish = new StringBuilder();
// case(a, b, c) -> $cond:[a, b, c]
// case(a, b, c, d) -> $cond:[a, b, $cond:[c, d, null]]
// case(a, b, c, d, e) -> $cond:[a, b, $cond:[c, d, e]]
for (int i = 0; i < strings.size(); i += 2) {
sb.append("{$cond:[");
finish.append("]}");
sb.append(strings.get(i));
sb.append(',');
sb.append(strings.get(i + 1));
sb.append(',');
if (i == strings.size() - 3) {
sb.append(strings.get(i + 2));
break;
}
if (i == strings.size() - 2) {
sb.append("null");
break;
}
}
sb.append(finish);
return sb.toString();
}
throw new IllegalArgumentException("Translation of " + call.toString()
+ " is not supported by MongoProject");
}
示例9: visitCall
@Override public String visitCall(RexCall call) {
if (call.op == SqlStdOperatorTable.ITEM) {
return ((RexLiteral) call.getOperands().get(1)).getValueAs(String.class);
}
return super.visitCall(call);
}