Java Code Examples for org.apache.calcite.sql.SqlFunctionCategory#USER_DEFINED_TABLE_FUNCTION

The following examples show how to use org.apache.calcite.sql.SqlFunctionCategory#USER_DEFINED_TABLE_FUNCTION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionCatalogOperatorTable.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("RedundantIfStatement")
private boolean verifyFunctionKind(
		@Nullable SqlFunctionCategory category,
		FunctionDefinition definition) {

	// for now, we don't allow other functions than user-defined ones
	// all built-in functions need to be mapped to Calcite's SqlFunctions
	if (!(definition instanceof UserDefinedFunction)) {
		return false;
	}

	// it would be nice to give a more meaningful exception when a scalar function is used instead
	// of a table function and vice versa, but we can do that only once FLIP-51 is implemented

	if (definition.getKind() == FunctionKind.SCALAR &&
			(category == SqlFunctionCategory.USER_DEFINED_FUNCTION || category == SqlFunctionCategory.SYSTEM)) {
		return true;
	} else if (definition.getKind() == FunctionKind.TABLE &&
			(category == SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION || category == SqlFunctionCategory.SYSTEM)) {
		return true;
	}

	// aggregate function are not supported, because the code generator is not ready yet

	return false;
}
 
Example 2
Source File: SqlUserDefinedTableMacro.java    From Bats with Apache License 2.0 5 votes vote down vote up
public SqlUserDefinedTableMacro(SqlIdentifier opName,
    SqlReturnTypeInference returnTypeInference,
    SqlOperandTypeInference operandTypeInference,
    SqlOperandTypeChecker operandTypeChecker, List<RelDataType> paramTypes,
    TableMacro tableMacro) {
  super(Util.last(opName.names), opName, SqlKind.OTHER_FUNCTION,
      returnTypeInference, operandTypeInference, operandTypeChecker,
      Objects.requireNonNull(paramTypes),
      SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
  this.tableMacro = tableMacro;
}
 
Example 3
Source File: SqlUserDefinedTableFunction.java    From Bats with Apache License 2.0 5 votes vote down vote up
public SqlUserDefinedTableFunction(SqlIdentifier opName,
    SqlReturnTypeInference returnTypeInference,
    SqlOperandTypeInference operandTypeInference,
    SqlOperandTypeChecker operandTypeChecker,
    List<RelDataType> paramTypes,
    TableFunction function) {
  super(opName, returnTypeInference, operandTypeInference, operandTypeChecker,
      paramTypes, function, SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
}
 
Example 4
Source File: DremioCatalogReader.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public void lookupOperatorOverloads(final SqlIdentifier paramSqlIdentifier, SqlFunctionCategory paramSqlFunctionCategory, SqlSyntax paramSqlSyntax, List<SqlOperator> paramList) {
  if(paramSqlFunctionCategory != SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION) {
    return;
  }

  paramList.addAll(FluentIterable.from(catalog.getFunctions(new NamespaceKey(paramSqlIdentifier.names))).transform(new com.google.common.base.Function<org.apache.calcite.schema.Function, SqlOperator>(){

    @Override
    public SqlOperator apply(Function input) {
      return toOp(paramSqlIdentifier, input);
    }}).toList());
}
 
Example 5
Source File: SqlUserDefinedTableMacro.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlUserDefinedTableMacro(SqlIdentifier opName,
    SqlReturnTypeInference returnTypeInference,
    SqlOperandTypeInference operandTypeInference,
    SqlOperandTypeChecker operandTypeChecker, List<RelDataType> paramTypes,
    TableMacro tableMacro) {
  super(Util.last(opName.names), opName, SqlKind.OTHER_FUNCTION,
      returnTypeInference, operandTypeInference, operandTypeChecker,
      Objects.requireNonNull(paramTypes),
      SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
  this.tableMacro = tableMacro;
}
 
Example 6
Source File: SqlUserDefinedTableFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlUserDefinedTableFunction(SqlIdentifier opName,
    SqlReturnTypeInference returnTypeInference,
    SqlOperandTypeInference operandTypeInference,
    SqlOperandTypeChecker operandTypeChecker,
    List<RelDataType> paramTypes,
    TableFunction function) {
  super(opName, returnTypeInference, operandTypeInference, operandTypeChecker,
      paramTypes, function, SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
}