Skip to main content
Version: 5.0.0

Operators

This chapter will introduce operators that applicable to SQL statements.

Arithmetic Operators

OperatorDescriptionSyntaxExample
+Plus operatorA + BCost + Profit
-Minus operatorA - BRevenue - Cost
*Multiply operatorA * BUnit_Price * Quantity
/Divide operatorA / BTotal_Sale / Quantity

Comparison Operators

OperatorDescriptionSyntaxExample
<Less thanA < Bcol1 < col2
<=Less than or equalA <= Bcol1 <= col2
>Greater thanA >= Bcol1 > col2
>=Greater than or equalA >= Bcol1 >= col2
<>Not EqualA <> Bcol1 <> col2
IS NULLWhether value is nullvalue IS NULLcol1 IS NULL
IS NOT NULLWhether value is not nullvalue IS NOT NULLcol1 IS NOT NULL
IS DISTINCT FROMWhether two values are not equal, treating null values as the samevalue1 IS DISTINCT FROM value2col1 IS DISTINCT FROM col2
IS NOT DISTINCT FROMWhether two values are equal, treating null values as the samevalue1 IS NOT DISTINCT FROM value2col1 IS NOT DISTINCT FROM col2
BETWEENReturn true if the specified value is greater than or equal to value1 and less than or equal to value2A BETWEEN value1 AND value2col1 BETWEEN '2016-01-01' AND '2016-12-30'
NOT BETWEENWhether value1 is less than value2 or greater than value3value1 NOT BETWEEN value2 AND value3col1 NOT BETWEEN '2016-01-01' AND '2016-12-30'
LIKEWhether string1 matches pattern string2, string1 and string2 are string typesstring1 LIKE string2col1 LIKE '%frank%'
NOT LIKEWhether string1 does not match pattern string2, string1 and string2 are string typesstring1 NOT LIKE string2 [ ESCAPE string3 ]col1 NOT LIKE '%frank%'
SIMILAR TOWhether string1 matches string2 in regular expressionstring1 SIMILAR TO string2col1 SIMILAR TO 'frank'
NOT SIMILAR TOWhether string1 does not match string2 in regular expressionstring1 NOT SIMILAR TO string2col1 NOT SIMILAR TO 'frank'

Limitations

  • The current SIMILAR TO ESCAPE syntax is limited to scenarios that support adding and hitting the model in SQL statements, and other scenarios such as adding computable columns.
  • The string literals including specific symbols need to be escaped by default and the escape character is \. For example, to match \kylin , it should be using \\kylin. For SIMILAR TO and NOT SIMILAR TO function, the functions use regex match and there is an escaped process. For example, for \\\\kylin, the result will be true when using SIMILAR TO to compare with \kylin and \\kylin.

Logical Operators

This section introduces the logical operators supported by Apache Kylin. The values of logical propositions are TRUE, FALSE, and UNKNOWN. The following boolean refers to a logical proposition.

OperatorDescriptionSyntaxExample
ANDWhether boolean1 and boolean2 are both TRUEboolean1 AND boolean2Name ='frank' AND gender='M'
ORWhether boolean1 is TRUE or boolean2 is TRUEboolean1 OR boolean2Name='frank' OR Name='Hentry'
NOTWhether boolean is not TRUE; returns UNKNOWN if boolean is UNKNOWNNOT booleanNOT (NAME ='frank')
IS FALSEWhether boolean is FALSE; returns FALSE if boolean is UNKNOWNboolean IS FALSEName ='frank' IS FALSE
IS NOT FALSEWhether boolean is not FALSE; returns TRUE if boolean is UNKNOWNboolean IS NOT FALSEName ='frank' IS NOT FALSE
IS TRUEWhether boolean is TRUE; returns FALSE if boolean is UNKNOWNboolean IS TRUEName ='frank' IS TRUE
IS NOT TRUEWhether boolean is not TRUE; returns TRUE if boolean is UNKNOWNboolean IS NOT TRUEName ='frank' IS NOT TRUE

String Operators

OperatorDescriptionSyntaxExample
||Concatenates two strings or string columnsA || BFirst_name || Last_name