Search in sources :

Example 41 with SqlLiteral

use of org.apache.calcite.sql.SqlLiteral in project drill by apache.

the class MetastoreAnalyzeTableHandler method getMetadataType.

private MetadataType getMetadataType(SqlMetastoreAnalyzeTable sqlAnalyzeTable) {
    SqlLiteral stringLiteral = sqlAnalyzeTable.getLevel();
    // for the case when metadata level is not specified in ANALYZE statement,
    // value from the `metastore.metadata.store.depth_level` option is used
    String metadataLevel;
    if (stringLiteral == null) {
        metadataLevel = context.getOption(ExecConstants.METASTORE_METADATA_STORE_DEPTH_LEVEL).string_val;
    } else {
        metadataLevel = stringLiteral.toValue();
    }
    return metadataLevel != null ? MetadataType.valueOf(metadataLevel.toUpperCase()) : MetadataType.ALL;
}
Also used : SqlLiteral(org.apache.calcite.sql.SqlLiteral)

Example 42 with SqlLiteral

use of org.apache.calcite.sql.SqlLiteral in project hive by apache.

the class HiveJdbcImplementor method visit.

@Override
public Result visit(Join e) {
    final Result leftResult = visitInput(e, 0).resetAlias();
    final Result rightResult = visitInput(e, 1).resetAlias();
    final Context leftContext = leftResult.qualifiedContext();
    final Context rightContext = rightResult.qualifiedContext();
    SqlNode sqlCondition = null;
    SqlLiteral condType = JoinConditionType.ON.symbol(POS);
    JoinType joinType = joinType(e.getJoinType());
    if (e.getJoinType() == JoinRelType.INNER && e.getCondition().isAlwaysTrue()) {
        joinType = JoinType.COMMA;
        condType = JoinConditionType.NONE.symbol(POS);
    } else {
        sqlCondition = convertConditionToSqlNode(e.getCondition(), leftContext, rightContext, e.getLeft().getRowType().getFieldCount());
    }
    SqlNode join = new SqlJoin(POS, leftResult.asFrom(), SqlLiteral.createBoolean(false, POS), joinType.symbol(POS), rightResult.asFrom(), condType, sqlCondition);
    return result(join, leftResult, rightResult);
}
Also used : SqlJoin(org.apache.calcite.sql.SqlJoin) JoinType(org.apache.calcite.sql.JoinType) SqlLiteral(org.apache.calcite.sql.SqlLiteral) SqlNode(org.apache.calcite.sql.SqlNode)

Aggregations

SqlLiteral (org.apache.calcite.sql.SqlLiteral)42 SqlNode (org.apache.calcite.sql.SqlNode)19 RelDataType (org.apache.calcite.rel.type.RelDataType)12 SqlCall (org.apache.calcite.sql.SqlCall)8 SqlNodeList (org.apache.calcite.sql.SqlNodeList)7 RexNode (org.apache.calcite.rex.RexNode)6 ArrayList (java.util.ArrayList)5 TimeUnitRange (org.apache.calcite.avatica.util.TimeUnitRange)5 NlsString (org.apache.calcite.util.NlsString)5 SqlBasicCall (org.apache.calcite.sql.SqlBasicCall)4 SqlIdentifier (org.apache.calcite.sql.SqlIdentifier)4 SqlMatchRecognize (org.apache.calcite.sql.SqlMatchRecognize)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Map (java.util.Map)3 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)3 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)3 RexLiteral (org.apache.calcite.rex.RexLiteral)3 SqlCallBinding (org.apache.calcite.sql.SqlCallBinding)3 BitString (org.apache.calcite.util.BitString)3 HashMap (java.util.HashMap)2