org.apache.calcite.rex.RexLiteral.getValue2()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.apache.calcite.rex.RexLiteral.getValue2方法的一些代码示例,展示了RexLiteral.getValue2的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RexLiteral.getValue2方法的具体详情如下:
包路径:org.apache.calcite.rex.RexLiteral
类名称:RexLiteral
方法名:getValue2

RexLiteral.getValue2介绍

[英]Returns the value of this literal, in the form that the calculator program builder wants it.
[中]以计算器程序生成器想要的形式返回此文本的值。

代码示例

代码示例来源:origin: apache/drill

patternStr = pattern.getValue().toString();
} else if (pattern.getTypeName() == SqlTypeName.CHAR) {
 patternStr = pattern.getValue2().toString();
 patternStr = pattern.getValue().toString();
} else if (pattern.getTypeName() == SqlTypeName.CHAR) {
 patternStr = pattern.getValue2().toString();
 escapeStr = escape.getValue().toString();
} else if (escape.getTypeName() == SqlTypeName.CHAR) {
 escapeStr = escape.getValue2().toString();

代码示例来源:origin: apache/hive

if (fetchExpr != null) {
 Object offset = (offsetExpr == null) ?
   new Integer(0) : ((RexLiteral) offsetExpr).getValue2();
 Object fetch = ((RexLiteral) fetchExpr).getValue2();
 hiveAST.limit = ASTBuilder.limit(offset, fetch);

代码示例来源:origin: apache/drill

if (fetchExpr != null) {
 Object offset = (offsetExpr == null) ?
   new Integer(0) : ((RexLiteral) offsetExpr).getValue2();
 Object fetch = ((RexLiteral) fetchExpr).getValue2();
 hiveAST.limit = ASTBuilder.limit(offset, fetch);

代码示例来源:origin: Qihoo360/Quicksql

private static Object literalValue(RexLiteral literal) {
 return literal.getValue2();
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

private void convertLimitToASTNode(HiveSort limit) {
 if (limit != null) {
  HiveSort hiveLimit = limit;
  RexNode limitExpr = hiveLimit.getFetchExpr();
  if (limitExpr != null) {
   Object val = ((RexLiteral) limitExpr).getValue2();
   hiveAST.limit = ASTBuilder.limit(val);
  }
 }
}

代码示例来源:origin: dremio/dremio-oss

private static boolean isLimit0(RexNode fetch) {
 if (fetch != null && fetch.isA(SqlKind.LITERAL)) {
  RexLiteral l = (RexLiteral) fetch;
  switch (l.getTypeName()) {
  case BIGINT:
  case INTEGER:
  case DECIMAL:
   if (((long) l.getValue2()) == 0) {
    return true;
   }
  }
 }
 return false;
}

代码示例来源:origin: Qihoo360/Quicksql

@Override public Void visitCall(RexCall call) {
  if (call.getOperator() == RexBuilder.GET_OPERATOR) {
   RexLiteral literal = (RexLiteral) call.getOperands().get(1);
   extraFields.add(
     new RelDataTypeFieldImpl(
       (String) literal.getValue2(),
       -1,
       call.getType()));
  }
  return super.visitCall(call);
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

@Override public Void visitCall(RexCall call) {
  if (call.getOperator() == RexBuilder.GET_OPERATOR) {
   RexLiteral literal = (RexLiteral) call.getOperands().get(1);
   extraFields.add(
     new RelDataTypeFieldImpl(
       (String) literal.getValue2(),
       -1,
       call.getType()));
  }
  return super.visitCall(call);
 }
}

代码示例来源:origin: Qihoo360/Quicksql

@Override public RexNode visitCall(RexCall call) {
 if (call.getOperator() == RexBuilder.GET_OPERATOR) {
  final String name =
    (String) ((RexLiteral) call.getOperands().get(1)).getValue2();
  final int i = lookup(fields, name);
  if (i >= 0) {
   return RexInputRef.of(i, fields);
  }
 }
 return super.visitCall(call);
}

代码示例来源:origin: org.apache.calcite/calcite-core

@Override public RexNode visitCall(RexCall call) {
 if (call.getOperator() == RexBuilder.GET_OPERATOR) {
  final String name =
    (String) ((RexLiteral) call.getOperands().get(1)).getValue2();
  final int i = lookup(fields, name);
  if (i >= 0) {
   return RexInputRef.of(i, fields);
  }
 }
 return super.visitCall(call);
}

代码示例来源:origin: org.apache.calcite/calcite-core

@Test public void testConstant() throws Exception {
 check((rexBuilder, executor) -> {
  final List<RexNode> reducedValues = new ArrayList<>();
  final RexLiteral ten = rexBuilder.makeExactLiteral(BigDecimal.TEN);
  executor.reduce(rexBuilder, ImmutableList.of(ten),
    reducedValues);
  assertThat(reducedValues.size(), equalTo(1));
  assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
  assertThat(((RexLiteral) reducedValues.get(0)).getValue2(),
    equalTo((Object) 10L));
 });
}

代码示例来源:origin: Qihoo360/Quicksql

@Test public void testConstant() throws Exception {
 check((rexBuilder, executor) -> {
  final List<RexNode> reducedValues = new ArrayList<>();
  final RexLiteral ten = rexBuilder.makeExactLiteral(BigDecimal.TEN);
  executor.reduce(rexBuilder, ImmutableList.of(ten),
    reducedValues);
  assertThat(reducedValues.size(), equalTo(1));
  assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
  assertThat(((RexLiteral) reducedValues.get(0)).getValue2(),
    equalTo((Object) 10L));
 });
}

代码示例来源:origin: Qihoo360/Quicksql

private void checkTimestamp(RexNode node) {
 assertThat(node.toString(), is("1969-07-21 02:56:15"));
 RexLiteral literal = (RexLiteral) node;
 assertThat(literal.getValue() instanceof Calendar, is(true));
 assertThat(literal.getValue2() instanceof Long, is(true));
 assertThat(literal.getValue3() instanceof Long, is(true));
 assertThat((Long) literal.getValue2(), is(MOON));
 assertThat(literal.getValueAs(Calendar.class), notNullValue());
 assertThat(literal.getValueAs(TimestampString.class), notNullValue());
}

代码示例来源:origin: org.apache.calcite/calcite-core

private void checkTimestamp(RexNode node) {
 assertThat(node.toString(), is("1969-07-21 02:56:15"));
 RexLiteral literal = (RexLiteral) node;
 assertThat(literal.getValue() instanceof Calendar, is(true));
 assertThat(literal.getValue2() instanceof Long, is(true));
 assertThat(literal.getValue3() instanceof Long, is(true));
 assertThat((Long) literal.getValue2(), is(MOON));
 assertThat(literal.getValueAs(Calendar.class), notNullValue());
 assertThat(literal.getValueAs(TimestampString.class), notNullValue());
}

代码示例来源:origin: org.apache.calcite/calcite-core

private void checkDate(RexNode node) {
 assertThat(node.toString(), is("1969-07-21"));
 RexLiteral literal = (RexLiteral) node;
 assertThat(literal.getValue() instanceof Calendar, is(true));
 assertThat(literal.getValue2() instanceof Integer, is(true));
 assertThat(literal.getValue3() instanceof Integer, is(true));
 assertThat((Integer) literal.getValue2(), is(MOON_DAY));
 assertThat(literal.getValueAs(Calendar.class), notNullValue());
 assertThat(literal.getValueAs(DateString.class), notNullValue());
}

代码示例来源:origin: org.apache.calcite/calcite-core

private void checkTime(RexNode node) {
 assertThat(node.toString(), is("02:56:15"));
 RexLiteral literal = (RexLiteral) node;
 assertThat(literal.getValue() instanceof Calendar, is(true));
 assertThat(literal.getValue2() instanceof Integer, is(true));
 assertThat(literal.getValue3() instanceof Integer, is(true));
 assertThat((Integer) literal.getValue2(), is(MOON_TIME));
 assertThat(literal.getValueAs(Calendar.class), notNullValue());
 assertThat(literal.getValueAs(TimeString.class), notNullValue());
}

代码示例来源:origin: Qihoo360/Quicksql

private void checkTime(RexNode node) {
 assertThat(node.toString(), is("02:56:15"));
 RexLiteral literal = (RexLiteral) node;
 assertThat(literal.getValue() instanceof Calendar, is(true));
 assertThat(literal.getValue2() instanceof Integer, is(true));
 assertThat(literal.getValue3() instanceof Integer, is(true));
 assertThat((Integer) literal.getValue2(), is(MOON_TIME));
 assertThat(literal.getValueAs(Calendar.class), notNullValue());
 assertThat(literal.getValueAs(TimeString.class), notNullValue());
}

代码示例来源:origin: Qihoo360/Quicksql

private void checkDate(RexNode node) {
 assertThat(node.toString(), is("1969-07-21"));
 RexLiteral literal = (RexLiteral) node;
 assertThat(literal.getValue() instanceof Calendar, is(true));
 assertThat(literal.getValue2() instanceof Integer, is(true));
 assertThat(literal.getValue3() instanceof Integer, is(true));
 assertThat((Integer) literal.getValue2(), is(MOON_DAY));
 assertThat(literal.getValueAs(Calendar.class), notNullValue());
 assertThat(literal.getValueAs(DateString.class), notNullValue());
}

代码示例来源:origin: org.apache.calcite/calcite-core

private void checkTimestampWithLocalTimeZone(RexNode node) {
 assertThat(node.toString(), is("1969-07-21 02:56:15"));
 RexLiteral literal = (RexLiteral) node;
 assertThat(literal.getValue() instanceof TimestampString, is(true));
 assertThat(literal.getValue2() instanceof Long, is(true));
 assertThat(literal.getValue3() instanceof Long, is(true));
}

代码示例来源:origin: Qihoo360/Quicksql

private void checkTimestampWithLocalTimeZone(RexNode node) {
 assertThat(node.toString(), is("1969-07-21 02:56:15"));
 RexLiteral literal = (RexLiteral) node;
 assertThat(literal.getValue() instanceof TimestampString, is(true));
 assertThat(literal.getValue2() instanceof Long, is(true));
 assertThat(literal.getValue3() instanceof Long, is(true));
}

相关文章