Tabnine Logo
NullLiteral
Code IndexAdd Tabnine to your IDE (free)

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

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

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

  return new NullLiteral();
return new Cast(new NullLiteral(), type.getTypeSignature().toString(), false, true);
origin: prestodb/presto

int index = insert.getColumns().indexOf(columns.get(column.getName()));
if (index < 0) {
  Expression cast = new Cast(new NullLiteral(), column.getType().getTypeSignature().toString());
  assignments.put(output, cast);
com.facebook.presto.sql.treeNullLiteral

Most used methods

  • <init>

Popular in Java

  • Parsing JSON documents to java classes using gson
  • requestLocationUpdates (LocationManager)
  • notifyDataSetChanged (ArrayAdapter)
  • addToBackStack (FragmentTransaction)
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now