org.apache.calcite.sql.fun.SqlMultisetValueConstructor Java Examples
The following examples show how to use
org.apache.calcite.sql.fun.SqlMultisetValueConstructor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandardConvertletTable.java From Bats with Apache License 2.0 | 5 votes |
public RexNode convertMultiset( SqlRexContext cx, SqlMultisetValueConstructor op, SqlCall call) { final RelDataType originalType = cx.getValidator().getValidatedNodeType(call); RexRangeRef rr = cx.getSubQueryExpr(call); assert rr != null; RelDataType msType = rr.getType().getFieldList().get(0).getType(); RexNode expr = cx.getRexBuilder().makeInputRef( msType, rr.getOffset()); assert msType.getComponentType().isStruct(); if (!originalType.getComponentType().isStruct()) { // If the type is not a struct, the multiset operator will have // wrapped the type as a record. Add a call to the $SLICE operator // to compensate. For example, // if '<ms>' has type 'RECORD (INTEGER x) MULTISET', // then '$SLICE(<ms>) has type 'INTEGER MULTISET'. // This will be removed as the expression is translated. expr = cx.getRexBuilder().makeCall(originalType, SqlStdOperatorTable.SLICE, ImmutableList.of(expr)); } return expr; }
Example #2
Source File: StandardConvertletTable.java From calcite with Apache License 2.0 | 5 votes |
public RexNode convertMultiset( SqlRexContext cx, SqlMultisetValueConstructor op, SqlCall call) { final RelDataType originalType = cx.getValidator().getValidatedNodeType(call); RexRangeRef rr = cx.getSubQueryExpr(call); assert rr != null; RelDataType msType = rr.getType().getFieldList().get(0).getType(); RexNode expr = cx.getRexBuilder().makeInputRef( msType, rr.getOffset()); assert msType.getComponentType().isStruct(); if (!originalType.getComponentType().isStruct()) { // If the type is not a struct, the multiset operator will have // wrapped the type as a record. Add a call to the $SLICE operator // to compensate. For example, // if '<ms>' has type 'RECORD (INTEGER x) MULTISET', // then '$SLICE(<ms>) has type 'INTEGER MULTISET'. // This will be removed as the expression is translated. expr = cx.getRexBuilder().makeCall(originalType, SqlStdOperatorTable.SLICE, ImmutableList.of(expr)); } return expr; }