Java Code Examples for org.apache.calcite.sql.SqlSyntax#PREFIX

The following examples show how to use org.apache.calcite.sql.SqlSyntax#PREFIX . 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: HiveSqlOperatorTable.java    From marble with Apache License 2.0 5 votes vote down vote up
private SqlSyntax[] getSqlSyntaxInCalcite(Class hiveUDFClass) {
  if (GenericUDFBaseBinary.class.isAssignableFrom(hiveUDFClass)) {
    return new SqlSyntax[]{SqlSyntax.BINARY, SqlSyntax.FUNCTION};
  } else if (GenericUDFBaseUnary.class.isAssignableFrom(hiveUDFClass)) {
    return new SqlSyntax[]{SqlSyntax.PREFIX, SqlSyntax.FUNCTION};
  } else if (hiveUDFClass.equals(UDFRegExp.class)) {
    //rlike
    return new SqlSyntax[]{SqlSyntax.SPECIAL, SqlSyntax.FUNCTION};
  } else {
    //we treat other udf classes as SqlSyntax.FUNCTION
    return new SqlSyntax[]{SqlSyntax.FUNCTION};
  }
}
 
Example 2
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static void findAllValidFunctionNames(
	List<String> names,
	SqlValidator validator,
	Collection<SqlMoniker> result,
	SqlParserPos pos) {
	// a function name can only be 1 part
	if (names.size() > 1) {
		return;
	}
	for (SqlOperator op : validator.getOperatorTable().getOperatorList()) {
		SqlIdentifier curOpId =
			new SqlIdentifier(
				op.getName(),
				pos);

		final SqlCall call =
			SqlUtil.makeCall(
				validator.getOperatorTable(),
				curOpId);
		if (call != null) {
			result.add(
				new SqlMonikerImpl(
					op.getName(),
					SqlMonikerType.FUNCTION));
		} else {
			if ((op.getSyntax() == SqlSyntax.FUNCTION)
				|| (op.getSyntax() == SqlSyntax.PREFIX)) {
				if (op.getOperandTypeChecker() != null) {
					String sig = op.getAllowedSignatures();
					sig = sig.replaceAll("'", "");
					result.add(
						new SqlMonikerImpl(
							sig,
							SqlMonikerType.FUNCTION));
					continue;
				}
				result.add(
					new SqlMonikerImpl(
						op.getName(),
						SqlMonikerType.FUNCTION));
			}
		}
	}
}
 
Example 3
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
private static void findAllValidFunctionNames(
	List<String> names,
	SqlValidator validator,
	Collection<SqlMoniker> result,
	SqlParserPos pos) {
	// a function name can only be 1 part
	if (names.size() > 1) {
		return;
	}
	for (SqlOperator op : validator.getOperatorTable().getOperatorList()) {
		SqlIdentifier curOpId =
			new SqlIdentifier(
				op.getName(),
				pos);

		final SqlCall call = validator.makeNullaryCall(curOpId);
		if (call != null) {
			result.add(
				new SqlMonikerImpl(
					op.getName(),
					SqlMonikerType.FUNCTION));
		} else {
			if ((op.getSyntax() == SqlSyntax.FUNCTION)
				|| (op.getSyntax() == SqlSyntax.PREFIX)) {
				if (op.getOperandTypeChecker() != null) {
					String sig = op.getAllowedSignatures();
					sig = sig.replaceAll("'", "");
					result.add(
						new SqlMonikerImpl(
							sig,
							SqlMonikerType.FUNCTION));
					continue;
				}
				result.add(
					new SqlMonikerImpl(
						op.getName(),
						SqlMonikerType.FUNCTION));
			}
		}
	}
}