Codota Logo
NullLiteral.<init>
Code IndexAdd Codota to your IDE (free)

How to use
com.facebook.presto.sql.tree.NullLiteral
constructor

Best Java code snippets using com.facebook.presto.sql.tree.NullLiteral.<init> (Showing top 20 results out of 315)

  • Common ways to obtain NullLiteral
private void myMethod () {
NullLiteral n =
  • Codota Iconnew NullLiteral()
  • Smart code suggestions by Codota
}
origin: prestodb/presto

@Override
public Node visitNullLiteral(SqlBaseParser.NullLiteralContext context)
{
  return new NullLiteral(getLocation(context));
}
origin: prestodb/presto

private static NullLiteral nullLiteral()
{
  return new NullLiteral();
}
origin: prestodb/presto

private static Expression booleanConstant(@Nullable Boolean value)
{
  if (value == null) {
    return new Cast(new NullLiteral(), BOOLEAN.toString());
  }
  return new BooleanLiteral(value.toString());
}
origin: prestodb/presto

  private static IfExpression createIfExpression(Expression left, Expression right, ComparisonExpression.Operator operator, Expression result, Type trueValueType)
  {
    return new IfExpression(
        new ComparisonExpression(operator, left, right),
        result,
        new Cast(new NullLiteral(), trueValueType.getTypeSignature().toString()));
  }
}
origin: prestodb/presto

private static void assertCast(String type, String expected)
{
  assertExpression("CAST(null AS " + type + ")", new Cast(new NullLiteral(), expected));
}
origin: prestodb/presto

private static Expression nullLiteral(Type type)
{
  return cast(new NullLiteral(), type);
}
origin: prestodb/presto

private PlanNode appendMarkers(PlanNode source, int markerIndex, List<Symbol> markers, Map<Symbol, SymbolReference> projections)
{
  Assignments.Builder assignments = Assignments.builder();
  // add existing intersect symbols to projection
  for (Map.Entry<Symbol, SymbolReference> entry : projections.entrySet()) {
    Symbol symbol = symbolAllocator.newSymbol(entry.getKey().getName(), symbolAllocator.getTypes().get(entry.getKey()));
    assignments.put(symbol, entry.getValue());
  }
  // add extra marker fields to the projection
  for (int i = 0; i < markers.size(); ++i) {
    Expression expression = (i == markerIndex) ? TRUE_LITERAL : new Cast(new NullLiteral(), StandardTypes.BOOLEAN);
    assignments.put(symbolAllocator.newSymbol(markers.get(i).getName(), BOOLEAN), expression);
  }
  return new ProjectNode(idAllocator.getNextId(), source, assignments.build());
}
origin: prestodb/presto

public ApplyNode apply(Assignments subqueryAssignments, List<Symbol> correlation, PlanNode input, PlanNode subquery)
{
  NullLiteral originSubquery = new NullLiteral(); // does not matter for tests
  return new ApplyNode(idAllocator.getNextId(), input, subquery, subqueryAssignments, correlation, originSubquery);
}
origin: prestodb/presto

NullLiteral nullLiteral = new NullLiteral();
ImmutableList.Builder<Symbol> nullSymbols = ImmutableList.builder();
ImmutableList.Builder<Expression> nullLiterals = ImmutableList.builder();
origin: prestodb/presto

public Expression rewriteUsingBounds(QuantifiedComparisonExpression quantifiedComparison, Symbol minValue, Symbol maxValue, Symbol countAllValue, Symbol countNonNullValue)
{
  BooleanLiteral emptySetResult = quantifiedComparison.getQuantifier().equals(ALL) ? TRUE_LITERAL : FALSE_LITERAL;
  Function<List<Expression>, Expression> quantifier = quantifiedComparison.getQuantifier().equals(ALL) ?
      ExpressionUtils::combineConjuncts : ExpressionUtils::combineDisjuncts;
  Expression comparisonWithExtremeValue = getBoundComparisons(quantifiedComparison, minValue, maxValue);
  return new SimpleCaseExpression(
      countAllValue.toSymbolReference(),
      ImmutableList.of(new WhenClause(
          new GenericLiteral("bigint", "0"),
          emptySetResult)),
      Optional.of(quantifier.apply(ImmutableList.of(
          comparisonWithExtremeValue,
          new SearchedCaseExpression(
              ImmutableList.of(
                  new WhenClause(
                      new ComparisonExpression(NOT_EQUAL, countAllValue.toSymbolReference(), countNonNullValue.toSymbolReference()),
                      new Cast(new NullLiteral(), BooleanType.BOOLEAN.toString()))),
              Optional.of(emptySetResult))))));
}
origin: prestodb/presto

public LateralJoinNode lateral(List<Symbol> correlation, PlanNode input, PlanNode subquery)
{
  NullLiteral originSubquery = new NullLiteral(); // does not matter for tests
  return new LateralJoinNode(idAllocator.getNextId(), input, subquery, correlation, LateralJoinNode.Type.INNER, originSubquery);
}
origin: prestodb/presto

@Override
protected Node visitDescribeInput(DescribeInput node, Void context)
    throws SemanticException
{
  String sqlString = session.getPreparedStatement(node.getName().getValue());
  Statement statement = parser.createStatement(sqlString, createParsingOptions(session));
  // create  analysis for the query we are describing.
  Analyzer analyzer = new Analyzer(session, metadata, parser, accessControl, queryExplainer, parameters, warningCollector);
  Analysis analysis = analyzer.analyze(statement, true);
  // get all parameters in query
  List<Parameter> parameters = getParameters(statement);
  // return the positions and types of all parameters
  Row[] rows = parameters.stream().map(parameter -> createDescribeInputRow(parameter, analysis)).toArray(Row[]::new);
  Optional<String> limit = Optional.empty();
  if (rows.length == 0) {
    rows = new Row[] {row(new NullLiteral(), new NullLiteral())};
    limit = Optional.of("0");
  }
  return simpleQuery(
      selectList(identifier("Position"), identifier("Type")),
      aliased(
          values(rows),
          "Parameter Input",
          ImmutableList.of("Position", "Type")),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.of(ordering(ascending("Position"))),
      limit);
}
origin: prestodb/presto

public ValuesNode values(PlanNodeId id, int rows, Symbol... columns)
{
  return values(
      id,
      ImmutableList.copyOf(columns),
      nElements(rows, row -> nElements(columns.length, cell -> (Expression) new NullLiteral())));
}
origin: prestodb/presto

@Test
public void testNullIf()
{
  assertExpression("nullif(42, 87)", new NullIfExpression(new LongLiteral("42"), new LongLiteral("87")));
  assertExpression("nullif(42, null)", new NullIfExpression(new LongLiteral("42"), new NullLiteral()));
  assertExpression("nullif(null, null)", new NullIfExpression(new NullLiteral(), new NullLiteral()));
  assertInvalidExpression("nullif(1)", "Invalid number of arguments for 'nullif' function");
  assertInvalidExpression("nullif(1, 2, 3)", "Invalid number of arguments for 'nullif' function");
  assertInvalidExpression("nullif(42, 87) filter (where true)", "FILTER not valid for 'nullif' function");
  assertInvalidExpression("nullif(42, 87) OVER ()", "OVER clause not valid for 'nullif' function");
}
origin: prestodb/presto

Row[] rows = analysis.getRootScope().getRelationType().getVisibleFields().stream().map(field -> createDescribeOutputRow(field, analysis)).toArray(Row[]::new);
if (rows.length == 0) {
  NullLiteral nullLiteral = new NullLiteral();
  rows = new Row[] {row(nullLiteral, nullLiteral, nullLiteral, nullLiteral, nullLiteral, nullLiteral, nullLiteral)};
  limit = Optional.of("0");
origin: prestodb/presto

@Test
public void testCoalesce()
{
  assertInvalidExpression("coalesce()", "The 'coalesce' function must have at least two arguments");
  assertInvalidExpression("coalesce(5)", "The 'coalesce' function must have at least two arguments");
  assertInvalidExpression("coalesce(1, 2) filter (where true)", "FILTER not valid for 'coalesce' function");
  assertInvalidExpression("coalesce(1, 2) OVER ()", "OVER clause not valid for 'coalesce' function");
  assertExpression("coalesce(13, 42)", new CoalesceExpression(new LongLiteral("13"), new LongLiteral("42")));
  assertExpression("coalesce(6, 7, 8)", new CoalesceExpression(new LongLiteral("6"), new LongLiteral("7"), new LongLiteral("8")));
  assertExpression("coalesce(13, null)", new CoalesceExpression(new LongLiteral("13"), new NullLiteral()));
  assertExpression("coalesce(null, 13)", new CoalesceExpression(new NullLiteral(), new LongLiteral("13")));
  assertExpression("coalesce(null, null)", new CoalesceExpression(new NullLiteral(), new NullLiteral()));
}
origin: prestodb/presto

@Test
public void testIf()
{
  assertExpression("if(true, 1, 0)", new IfExpression(new BooleanLiteral("true"), new LongLiteral("1"), new LongLiteral("0")));
  assertExpression("if(true, 3, null)", new IfExpression(new BooleanLiteral("true"), new LongLiteral("3"), new NullLiteral()));
  assertExpression("if(false, null, 4)", new IfExpression(new BooleanLiteral("false"), new NullLiteral(), new LongLiteral("4")));
  assertExpression("if(false, null, null)", new IfExpression(new BooleanLiteral("false"), new NullLiteral(), new NullLiteral()));
  assertExpression("if(true, 3)", new IfExpression(new BooleanLiteral("true"), new LongLiteral("3"), null));
  assertInvalidExpression("IF(true)", "Invalid number of arguments for 'if' function");
  assertInvalidExpression("IF(true, 1, 0) FILTER (WHERE true)", "FILTER not valid for 'if' function");
  assertInvalidExpression("IF(true, 1, 0) OVER()", "OVER clause not valid for 'if' function");
}
origin: prestodb/presto

@Test
public void testExpressionsThatMayReturnNullOnNonNullInput()
{
  List<Expression> candidates = ImmutableList.of(
      new Cast(nameReference("b"), "BIGINT", true), // try_cast
      new FunctionCall(QualifiedName.of("try"), ImmutableList.of(nameReference("b"))),
      new NullIfExpression(nameReference("b"), number(1)),
      new IfExpression(nameReference("b"), number(1), new NullLiteral()),
      new DereferenceExpression(nameReference("b"), identifier("x")),
      new InPredicate(nameReference("b"), new InListExpression(ImmutableList.of(new NullLiteral()))),
      new SearchedCaseExpression(ImmutableList.of(new WhenClause(new IsNotNullPredicate(nameReference("b")), new NullLiteral())), Optional.empty()),
      new SimpleCaseExpression(nameReference("b"), ImmutableList.of(new WhenClause(number(1), new NullLiteral())), Optional.empty()),
      new SubscriptExpression(new ArrayConstructor(ImmutableList.of(new NullLiteral())), nameReference("b")));
  for (Expression candidate : candidates) {
    EqualityInference.Builder builder = new EqualityInference.Builder();
    builder.extractInferenceCandidates(equals(nameReference("b"), nameReference("x")));
    builder.extractInferenceCandidates(equals(nameReference("a"), candidate));
    EqualityInference inference = builder.build();
    List<Expression> equalities = inference.generateEqualitiesPartitionedBy(matchesSymbols("b")).getScopeStraddlingEqualities();
    assertEquals(equalities.size(), 1);
    assertTrue(equalities.get(0).equals(equals(nameReference("x"), nameReference("b"))) || equalities.get(0).equals(equals(nameReference("b"), nameReference("x"))));
  }
}
origin: prestodb/presto

@Test
public void testFunctionCall()
{
  assertCalculate(
      new FunctionCall(
          QualifiedName.of("length"),
          ImmutableList.of(new Cast(new NullLiteral(), "VARCHAR(10)"))))
      .distinctValuesCount(0.0)
      .lowValueUnknown()
      .highValueUnknown()
      .nullsFraction(1.0);
  assertCalculate(
      new FunctionCall(
          QualifiedName.of("length"),
          ImmutableList.of(new SymbolReference("x"))),
      PlanNodeStatsEstimate.unknown(),
      TypeProvider.viewOf(ImmutableMap.of(new Symbol("x"), createVarcharType(2))))
      .distinctValuesCountUnknown()
      .lowValueUnknown()
      .highValueUnknown()
      .nullsFractionUnknown();
}
origin: prestodb/presto

outputSymbols.put(aggregateInfo.getMask(), new NullLiteral());
com.facebook.presto.sql.treeNullLiteral<init>

Popular methods of NullLiteral

    Popular in Java

    • Updating database using SQL prepared statement
    • getExternalFilesDir (Context)
    • findViewById (Activity)
    • onRequestPermissionsResult (Fragment)
    • GridBagLayout (java.awt)
      The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
    • ConnectException (java.net)
      A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
    • Calendar (java.util)
      Calendar is an abstract base class for converting between a Date object and a set of integer fields
    • Collection (java.util)
      Collection is the root of the collection hierarchy. It defines operations on data collections and t
    • Stream (java.util.stream)
      A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
    • JButton (javax.swing)
    Codota Logo
    • Products

      Search for Java codeSearch for JavaScript codeEnterprise
    • IDE Plugins

      IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Codota for your IDE now