use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.parser.SqlParserPos in project hive by apache.
the class RexNodeExprFactory method createIntervalDayConstantExpr.
/**
* {@inheritDoc}
*/
@Override
protected RexLiteral createIntervalDayConstantExpr(String value) {
HiveIntervalDayTime v = new HiveIntervalDayTime(Integer.parseInt(value), 0, 0, 0, 0);
BigDecimal secsValueBd = BigDecimal.valueOf(v.getTotalSeconds() * 1000);
BigDecimal nanosValueBd = BigDecimal.valueOf((v).getNanos(), 6);
return rexBuilder.makeIntervalLiteral(secsValueBd.add(nanosValueBd), new SqlIntervalQualifier(TimeUnit.MILLISECOND, null, new SqlParserPos(1, 1)));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.parser.SqlParserPos in project hive by apache.
the class RexNodeExprFactory method createIntervalYearConstantExpr.
/**
* {@inheritDoc}
*/
@Override
protected RexLiteral createIntervalYearConstantExpr(String value) {
HiveIntervalYearMonth v = new HiveIntervalYearMonth(Integer.parseInt(value), 0);
BigDecimal totalMonths = BigDecimal.valueOf(v.getTotalMonths());
return rexBuilder.makeIntervalLiteral(totalMonths, new SqlIntervalQualifier(TimeUnit.YEAR, TimeUnit.MONTH, new SqlParserPos(1, 1)));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.parser.SqlParserPos in project hive by apache.
the class RexNodeExprFactory method createIntervalMinuteConstantExpr.
/**
* {@inheritDoc}
*/
@Override
protected RexLiteral createIntervalMinuteConstantExpr(String value) {
HiveIntervalDayTime v = new HiveIntervalDayTime(0, 0, Integer.parseInt(value), 0, 0);
BigDecimal secsValueBd = BigDecimal.valueOf(v.getTotalSeconds() * 1000);
BigDecimal nanosValueBd = BigDecimal.valueOf((v).getNanos(), 6);
return rexBuilder.makeIntervalLiteral(secsValueBd.add(nanosValueBd), new SqlIntervalQualifier(TimeUnit.MILLISECOND, null, new SqlParserPos(1, 1)));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.parser.SqlParserPos in project drill by apache.
the class DrillAvgVarianceConvertlet method expandAvg.
private SqlNode expandAvg(final SqlNode arg) {
final SqlParserPos pos = SqlParserPos.ZERO;
final SqlNode sum = SqlStdOperatorTable.SUM.createCall(pos, arg);
final SqlNode count = SqlStdOperatorTable.COUNT.createCall(pos, arg);
final SqlNode sumAsDouble = CastHighOp.createCall(pos, sum);
return SqlStdOperatorTable.DIVIDE.createCall(pos, sumAsDouble, count);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.parser.SqlParserPos in project drill by apache.
the class TestDrillSQLWorker method testErrorFormating.
@Test
public void testErrorFormating() {
String sql = "Select * from Foo\nwhere tadadidada;\n";
validateFormattedIs(sql, new SqlParserPos(1, 2), "Select * from Foo\n" + " ^\n" + "where tadadidada;\n");
validateFormattedIs(sql, new SqlParserPos(2, 2), "Select * from Foo\n" + "where tadadidada;\n" + " ^\n");
validateFormattedIs(sql, new SqlParserPos(1, 10), "Select * from Foo\n" + " ^\n" + "where tadadidada;\n");
validateFormattedIs(sql, new SqlParserPos(-11, -10), sql);
validateFormattedIs(sql, new SqlParserPos(0, 10), sql);
validateFormattedIs(sql, new SqlParserPos(100, 10), sql);
}
Aggregations