Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.facebook.presto.sql.relational;
 
 
 import java.util.List;
 
 import static com.facebook.presto.metadata.FunctionRegistry.mangleOperatorName;
 import static com.facebook.presto.metadata.OperatorType.SUBSCRIPT;
 import static com.facebook.presto.metadata.Signature.internalFunction;
 import static com.facebook.presto.metadata.Signature.internalOperator;
 import static com.facebook.presto.spi.type.TypeSignature.parseTypeSignature;
 import static com.facebook.presto.sql.tree.ArrayConstructor.ARRAY_CONSTRUCTOR;
 
 public final class Signatures
 {
     public static final String IF = "IF";
     public static final String NULL_IF = "NULL_IF";
     public static final String SWITCH = "SWITCH";
     public static final String CAST = mangleOperatorName("CAST");
     public static final String TRY_CAST = "TRY_CAST";
     public static final String IS_NULL = "IS_NULL";
     public static final String COALESCE = "COALESCE";
     public static final String IN = "IN";
 
     private Signatures()
     {
     }
 
     // **************** sql operators ****************
     public static Signature notSignature()
     {
         return new Signature("not"., ImmutableList.of(.));
     }
 
     public static Signature betweenSignature(Type valueTypeType minTypeType maxType)
     {
         return internalOperator("BETWEEN"parseTypeSignature(.), valueType.getTypeSignature(), minType.getTypeSignature(), maxType.getTypeSignature());
     }
 
     public static Signature likeSignature()
     {
     }
 
     public static Signature likePatternSignature()
     {
         return internalFunction("LIKE_PATTERN"...);
     }
 
     public static Signature castSignature(Type returnTypeType valueType)
     {
         // Name has already been mangled, so don't use internalOperator
         return internalFunction(returnType.getTypeSignature(), valueType.getTypeSignature());
     }
 
     public static Signature tryCastSignature(Type returnTypeType valueType)
     {
         return internalFunction(returnType.getTypeSignature(), valueType.getTypeSignature());
     }
 
     public static Signature logicalExpressionSignature(LogicalBinaryExpression.Type expressionType)
     {
         return internalFunction(expressionType.name(), ...);
     }
 
     public static Signature arithmeticNegationSignature(Type returnTypeType valueType)
     {
         return internalOperator("NEGATION"returnType.getTypeSignature(), valueType.getTypeSignature());
     }
 
     public static Signature arithmeticExpressionSignature(ArithmeticBinaryExpression.Type expressionTypeType returnTypeType leftTypeType rightType)
     {
         return internalOperator(expressionType.name(), returnType.getTypeSignature(), leftType.getTypeSignature(), rightType.getTypeSignature());
     }
 
     public static Signature subscriptSignature(Type returnTypeType leftTypeType rightType)
    {
        return internalOperator(.name(), returnType.getTypeSignature(), leftType.getTypeSignature(), rightType.getTypeSignature());
    }
    public static Signature arrayConstructorSignature(Type returnTypeList<? extends TypeargumentTypes)
    {
        return internalFunction(returnType.getTypeSignature(), Lists.transform(argumentTypes, Type::getTypeSignature));
    }
    public static Signature arrayConstructorSignature(TypeSignature returnTypeList<TypeSignatureargumentTypes)
    {
        return internalFunction(returnTypeargumentTypes);
    }
    public static Signature comparisonExpressionSignature(ComparisonExpression.Type expressionTypeType leftTypeType rightType)
    {
        for (OperatorType operatorType : OperatorType.values()) {
            if (operatorType.name().equals(expressionType.name())) {
                return internalOperator(expressionType.name(), parseTypeSignature(.), leftType.getTypeSignature(), rightType.getTypeSignature());
            }
        }
        return internalFunction(expressionType.name(), parseTypeSignature(.), leftType.getTypeSignature(), rightType.getTypeSignature());
    }
    // **************** special forms (lazy evaluation, etc) ****************
    public static Signature ifSignature(Type returnType)
    {
        return new Signature(returnType.getTypeSignature());
    }
    public static Signature nullIfSignature(Type returnTypeType firstTypeType secondType)
    {
        return new Signature(returnType.getTypeSignature(), firstType.getTypeSignature(), secondType.getTypeSignature());
    }
    public static Signature switchSignature(Type returnType)
    {
        return new Signature(returnType.getTypeSignature());
    }
    public static Signature whenSignature(Type returnType)
    {
        return new Signature("WHEN"returnType.getTypeSignature());
    }
    // **************** functions that require varargs and/or complex types (e.g., lists) ****************
    public static Signature inSignature()
    {
        return internalFunction(.);
    }
    // **************** functions that need to do special null handling ****************
    public static Signature isNullSignature(Type argumentType)
    {
    }
    public static Signature coalesceSignature(Type returnTypeList<TypeargumentTypes)
    {
        return internalFunction(returnType.getTypeSignature(), Lists.transform(argumentTypes, Type::getTypeSignature));
    }
New to GrepCode? Check out our FAQ X