-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Functor10/master
Add functions control and Elasticsearch related features.
- Loading branch information
Showing
51 changed files
with
1,431 additions
and
667 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
analysis/src/main/java/org/apache/calcite/sql/fun/SqlIfFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.apache.calcite.sql.fun; | ||
|
||
import java.util.List; | ||
import org.apache.calcite.sql.SqlCallBinding; | ||
import org.apache.calcite.sql.SqlFunction; | ||
import org.apache.calcite.sql.SqlFunctionCategory; | ||
import org.apache.calcite.sql.SqlKind; | ||
import org.apache.calcite.sql.SqlNode; | ||
import org.apache.calcite.sql.SqlOperandCountRange; | ||
import org.apache.calcite.sql.SqlOperatorBinding; | ||
import org.apache.calcite.sql.type.InferTypes; | ||
import org.apache.calcite.sql.type.OperandTypes; | ||
import org.apache.calcite.sql.type.ReturnTypes; | ||
import org.apache.calcite.sql.type.SqlOperandCountRanges; | ||
import org.apache.calcite.sql.validate.SqlMonotonicity; | ||
|
||
public class SqlIfFunction extends SqlFunction { | ||
public SqlIfFunction() { | ||
super("IF", | ||
SqlKind.OTHER_FUNCTION, | ||
ReturnTypes.ARG1_NULLABLE, | ||
InferTypes.RETURN_TYPE, | ||
null, | ||
SqlFunctionCategory.STRING); | ||
} | ||
|
||
@Override | ||
public boolean checkOperandTypes( | ||
SqlCallBinding callBinding, | ||
boolean throwOnFailure | ||
) { | ||
final List<SqlNode> operands = callBinding.operands(); | ||
int n = operands.size(); | ||
assert (3 == n); | ||
//TODO add type checker | ||
return OperandTypes.BOOLEAN.checkSingleOperandType( | ||
callBinding, operands.get(0), 0, throwOnFailure); | ||
} | ||
|
||
@Override | ||
public SqlOperandCountRange getOperandCountRange() { | ||
return SqlOperandCountRanges.between(3, 3); | ||
} | ||
|
||
@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) { | ||
return SqlMonotonicity.INCREASING; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
analysis/src/main/java/org/apache/calcite/sql/fun/SqlRegexpExtractFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.apache.calcite.sql.fun; | ||
|
||
import java.util.List; | ||
import org.apache.calcite.sql.SqlCallBinding; | ||
import org.apache.calcite.sql.SqlFunction; | ||
import org.apache.calcite.sql.SqlFunctionCategory; | ||
import org.apache.calcite.sql.SqlKind; | ||
import org.apache.calcite.sql.SqlNode; | ||
import org.apache.calcite.sql.SqlOperandCountRange; | ||
import org.apache.calcite.sql.SqlOperatorBinding; | ||
import org.apache.calcite.sql.type.OperandTypes; | ||
import org.apache.calcite.sql.type.ReturnTypes; | ||
import org.apache.calcite.sql.type.SqlOperandCountRanges; | ||
import org.apache.calcite.sql.validate.SqlMonotonicity; | ||
|
||
//Updated by qsql-team | ||
public class SqlRegexpExtractFunction extends SqlFunction { | ||
public SqlRegexpExtractFunction() { | ||
super( | ||
"REGEXP_EXTRACT", | ||
SqlKind.OTHER_FUNCTION, | ||
ReturnTypes.ARG0_NULLABLE_VARYING, | ||
null, | ||
null, | ||
SqlFunctionCategory.STRING); | ||
} | ||
|
||
@Override | ||
public boolean checkOperandTypes( | ||
SqlCallBinding callBinding, | ||
boolean throwOnFailure | ||
) { | ||
final List<SqlNode> operands = callBinding.operands(); | ||
int n = operands.size(); | ||
assert (3 == n); | ||
|
||
return OperandTypes.STRING | ||
.checkSingleOperandType(callBinding, operands.get(0), 0, throwOnFailure) | ||
&& OperandTypes.STRING | ||
.checkSingleOperandType(callBinding, operands.get(1), 0, throwOnFailure) | ||
&& OperandTypes.NUMERIC | ||
.checkSingleOperandType(callBinding, operands.get(2), 0, throwOnFailure); | ||
} | ||
|
||
public SqlOperandCountRange getOperandCountRange() { | ||
return SqlOperandCountRanges.between(3, 3); | ||
} | ||
|
||
@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) { | ||
return SqlMonotonicity.INCREASING; | ||
} | ||
|
||
|
||
} |
53 changes: 53 additions & 0 deletions
53
analysis/src/main/java/org/apache/calcite/sql/fun/SqlRegexpReplaceFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.apache.calcite.sql.fun; | ||
|
||
import java.util.List; | ||
import org.apache.calcite.sql.SqlCallBinding; | ||
import org.apache.calcite.sql.SqlFunction; | ||
import org.apache.calcite.sql.SqlFunctionCategory; | ||
import org.apache.calcite.sql.SqlKind; | ||
import org.apache.calcite.sql.SqlNode; | ||
import org.apache.calcite.sql.SqlOperandCountRange; | ||
import org.apache.calcite.sql.SqlOperatorBinding; | ||
import org.apache.calcite.sql.type.OperandTypes; | ||
import org.apache.calcite.sql.type.ReturnTypes; | ||
import org.apache.calcite.sql.type.SqlOperandCountRanges; | ||
import org.apache.calcite.sql.validate.SqlMonotonicity; | ||
|
||
//Updated by qsql-team | ||
public class SqlRegexpReplaceFunction extends SqlFunction { | ||
public SqlRegexpReplaceFunction() { | ||
super( | ||
"REGEXP_REPLACE", | ||
SqlKind.OTHER_FUNCTION, | ||
ReturnTypes.ARG0_NULLABLE_VARYING, | ||
null, | ||
null, | ||
SqlFunctionCategory.STRING); | ||
} | ||
|
||
@Override | ||
public boolean checkOperandTypes( | ||
SqlCallBinding callBinding, | ||
boolean throwOnFailure | ||
) { | ||
final List<SqlNode> operands = callBinding.operands(); | ||
int n = operands.size(); | ||
assert (3 == n); | ||
|
||
return OperandTypes.STRING | ||
.checkSingleOperandType(callBinding, operands.get(0), 0, throwOnFailure) | ||
&& OperandTypes.STRING | ||
.checkSingleOperandType(callBinding, operands.get(1), 0, throwOnFailure) | ||
&& OperandTypes.STRING | ||
.checkSingleOperandType(callBinding, operands.get(2), 0, throwOnFailure); | ||
} | ||
|
||
@Override | ||
public SqlOperandCountRange getOperandCountRange() { | ||
return SqlOperandCountRanges.between(3, 3); | ||
} | ||
|
||
@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) { | ||
return SqlMonotonicity.INCREASING; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.