Java Code Examples for org.apache.calcite.sql.type.SqlTypeUtil#inBooleanFamily()

The following examples show how to use org.apache.calcite.sql.type.SqlTypeUtil#inBooleanFamily() . 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: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
protected void validateWhereOrOn(
	SqlValidatorScope scope,
	SqlNode condition,
	String clause) {
	validateNoAggs(aggOrOverOrGroupFinder, condition, clause);
	inferUnknownTypes(
		booleanType,
		scope,
		condition);
	condition.validate(this, scope);

	final RelDataType type = deriveType(scope, condition);
	if (!SqlTypeUtil.inBooleanFamily(type)) {
		throw newValidationError(condition, RESOURCE.condMustBeBoolean(clause));
	}
}
 
Example 2
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 6 votes vote down vote up
protected void validateWhereOrOn(
	SqlValidatorScope scope,
	SqlNode condition,
	String clause) {
	validateNoAggs(aggOrOverOrGroupFinder, condition, clause);
	inferUnknownTypes(
		booleanType,
		scope,
		condition);
	condition.validate(this, scope);

	final RelDataType type = deriveType(scope, condition);
	if (!SqlTypeUtil.inBooleanFamily(type)) {
		throw newValidationError(condition, RESOURCE.condMustBeBoolean(clause));
	}
}
 
Example 3
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
protected void validateHavingClause(SqlSelect select) {
	// HAVING is validated in the scope after groups have been created.
	// For example, in "SELECT empno FROM emp WHERE empno = 10 GROUP BY
	// deptno HAVING empno = 10", the reference to 'empno' in the HAVING
	// clause is illegal.
	SqlNode having = select.getHaving();
	if (having == null) {
		return;
	}
	final AggregatingScope havingScope =
		(AggregatingScope) getSelectScope(select);
	if (getConformance().isHavingAlias()) {
		SqlNode newExpr = expandGroupByOrHavingExpr(having, havingScope, select, true);
		if (having != newExpr) {
			having = newExpr;
			select.setHaving(newExpr);
		}
	}
	havingScope.checkAggregateExpr(having, true);
	inferUnknownTypes(
		booleanType,
		havingScope,
		having);
	having.validate(this, havingScope);
	final RelDataType type = deriveType(havingScope, having);
	if (!SqlTypeUtil.inBooleanFamily(type)) {
		throw newValidationError(having, RESOURCE.havingMustBeBoolean());
	}
}
 
Example 4
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
protected void validateHavingClause(SqlSelect select) {
	// HAVING is validated in the scope after groups have been created.
	// For example, in "SELECT empno FROM emp WHERE empno = 10 GROUP BY
	// deptno HAVING empno = 10", the reference to 'empno' in the HAVING
	// clause is illegal.
	SqlNode having = select.getHaving();
	if (having == null) {
		return;
	}
	final AggregatingScope havingScope =
		(AggregatingScope) getSelectScope(select);
	if (getConformance().isHavingAlias()) {
		SqlNode newExpr = expandGroupByOrHavingExpr(having, havingScope, select, true);
		if (having != newExpr) {
			having = newExpr;
			select.setHaving(newExpr);
		}
	}
	havingScope.checkAggregateExpr(having, true);
	inferUnknownTypes(
		booleanType,
		havingScope,
		having);
	having.validate(this, havingScope);
	final RelDataType type = deriveType(havingScope, having);
	if (!SqlTypeUtil.inBooleanFamily(type)) {
		throw newValidationError(having, RESOURCE.havingMustBeBoolean());
	}
}
 
Example 5
Source File: RexTransformer.java    From Bats with Apache License 2.0 4 votes vote down vote up
private boolean isBoolean(RexNode node) {
  RelDataType type = node.getType();
  return SqlTypeUtil.inBooleanFamily(type);
}
 
Example 6
Source File: RexTransformer.java    From calcite with Apache License 2.0 4 votes vote down vote up
private boolean isBoolean(RexNode node) {
  RelDataType type = node.getType();
  return SqlTypeUtil.inBooleanFamily(type);
}