Skip to content

Commit

Permalink
use ImmutableSet for substring operator names
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGe00 committed Apr 11, 2024
1 parent 9048f65 commit 1748c33
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

import java.util.Arrays;
import java.util.List;
import java.util.Set;

import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlIdentifier;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlNumericLiteral;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;

import com.linkedin.coral.com.google.common.collect.ImmutableSet;
import com.linkedin.coral.common.calcite.CalciteUtil;
import com.linkedin.coral.common.transformers.SqlCallTransformer;

Expand All @@ -29,10 +31,10 @@
* This transformer guarantees that starting index will always 1 or greater.
*/
public class SubstrIndexTransformer extends SqlCallTransformer {
private final static Set<String> SUBSTRING_OPERATORS = ImmutableSet.of("substr", "substring");
@Override
protected boolean condition(SqlCall sqlCall) {
return sqlCall.getOperator().getName().toLowerCase() == "substr"
|| sqlCall.getOperator().getName().toLowerCase() == "substring";
return SUBSTRING_OPERATORS.contains(sqlCall.getOperator().getName().toLowerCase());
}

@Override
Expand Down

0 comments on commit 1748c33

Please sign in to comment.