congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
NullIfExpression
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: prestodb/presto

@Override
protected Object visitNullIfExpression(NullIfExpression node, Object context)
  Object first = process(node.getFirst(), context);
  if (first == null) {
    return null;
  Object second = process(node.getSecond(), context);
  if (second == null) {
    return first;
  Type firstType = type(node.getFirst());
  Type secondType = type(node.getSecond());
    return new NullIfExpression(toExpression(first, firstType), toExpression(second, secondType));
origin: prestodb/presto

@Override
protected R visitNullIfExpression(NullIfExpression node, C context)
{
  process(node.getFirst(), context);
  process(node.getSecond(), context);
  return null;
}
origin: prestodb/presto

check(!filter.isPresent(), "FILTER not valid for 'nullif' function", context);
return new NullIfExpression(
    getLocation(context),
    (Expression) visit(context.expression(0)),
origin: prestodb/presto

@Override
protected String visitNullIfExpression(NullIfExpression node, Void context)
{
  return "NULLIF(" + process(node.getFirst(), context) + ", " + process(node.getSecond(), context) + ')';
}
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

@Override
protected Boolean visitNullIfExpression(NullIfExpression node, Void context)
{
  return process(node.getFirst(), context) && process(node.getSecond(), context);
}
origin: uk.co.nichesolutions.presto/presto-main

@Override
protected Object visitNullIfExpression(NullIfExpression node, Object context)
  Object first = process(node.getFirst(), context);
  if (first == null) {
    return null;
  Object second = process(node.getSecond(), context);
  if (second == null) {
    return first;
  Type firstType = expressionTypes.get(node.getFirst());
  Type secondType = expressionTypes.get(node.getSecond());
    return new NullIfExpression(toExpression(first, firstType), toExpression(second, secondType));
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

@Override
protected Type visitNullIfExpression(NullIfExpression node, StackableAstVisitorContext<Context> context)
{
  Type firstType = process(node.getFirst(), context);
  Type secondType = process(node.getSecond(), context);
  if (!typeManager.getCommonSuperType(firstType, secondType).isPresent()) {
    throw new SemanticException(TYPE_MISMATCH, node, "Types are not comparable with NULLIF: %s vs %s", firstType, secondType);
  }
  return setExpressionType(node, firstType);
}
origin: com.facebook.presto/presto-parser

check(!filter.isPresent(), "FILTER not valid for 'nullif' function", context);
return new NullIfExpression(
    getLocation(context),
    (Expression) visit(context.expression(0)),
origin: prestodb/presto

@Override
protected RowExpression visitNullIfExpression(NullIfExpression node, Void context)
{
  RowExpression first = process(node.getFirst(), context);
  RowExpression second = process(node.getSecond(), context);
  return call(
      nullIfSignature(getType(node), first.getType(), second.getType()),
      getType(node),
      first,
      second);
}
origin: com.facebook.presto/presto-parser

@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: rakam-io/rakam

@Override
protected String visitNullIfExpression(NullIfExpression node, Void context) {
  return "NULLIF(" + process(node.getFirst(), context) + ", " + process(node.getSecond(), context) + ')';
}
origin: uk.co.nichesolutions.presto/presto-parser

check(!distinct, "DISTINCT not valid for 'nullif' function", context);
return new NullIfExpression(
    getLocation(context),
    (Expression) visit(context.expression(0)),
origin: vqtran/EchoQuery

@Override
protected String visitNullIfExpression(NullIfExpression node, Boolean unmangleNames)
{
  return "NULLIF(" + process(node.getFirst(), unmangleNames) + ", " + process(node.getSecond(), unmangleNames) + ')';
}
origin: uk.co.nichesolutions.presto/presto-main

@Override
protected Boolean visitNullIfExpression(NullIfExpression node, Void context)
{
  return process(node.getFirst(), context) && process(node.getSecond(), context);
}
origin: com.facebook.presto/presto-parser

@Override
protected String visitNullIfExpression(NullIfExpression node, Void context)
{
  return "NULLIF(" + process(node.getFirst(), context) + ", " + process(node.getSecond(), context) + ')';
}
origin: com.facebook.presto/presto-parser

@Override
protected R visitNullIfExpression(NullIfExpression node, C context)
{
  process(node.getFirst(), context);
  process(node.getSecond(), context);
  return null;
}
origin: uk.co.nichesolutions.presto/presto-parser

@Override
protected String visitNullIfExpression(NullIfExpression node, Boolean unmangleNames)
{
  return "NULLIF(" + process(node.getFirst(), unmangleNames) + ", " + process(node.getSecond(), unmangleNames) + ')';
}
origin: uk.co.nichesolutions.presto/presto-parser

@Override
protected R visitNullIfExpression(NullIfExpression node, C context)
{
  process(node.getFirst(), context);
  process(node.getSecond(), context);
  return null;
}
com.facebook.presto.sql.treeNullIfExpression

Javadoc

NULLIF(V1,V2): CASE WHEN V1=V2 THEN NULL ELSE V1 END

Most used methods

  • <init>
  • getFirst
  • getSecond

Popular in Java

  • Making http requests using okhttp
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • setContentView (Activity)
  • Menu (java.awt)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • ImageIO (javax.imageio)
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JFrame (javax.swing)
  • Top Vim plugins
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