com.exasol.spark.common.CountStarStatementGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spark-connector-common-java Show documentation
Show all versions of spark-connector-common-java Show documentation
An Exasol common library for Apache Spark connectors
The newest version!
package com.exasol.spark.common;
import static com.exasol.sql.expression.ExpressionTerm.stringLiteral;
import static com.exasol.sql.expression.function.exasol.ExasolAnalyticAggregateFunctions.COUNT;
import com.exasol.sql.expression.BooleanExpression;
/**
* A class that generates Exasol {@code COUNT(*)} statement including where clauses if available.
*/
public final class CountStarStatementGenerator extends AbstractSelectStatementGenerator implements StatementGenerator {
/**
* Creates an instance of {@link CountStarStatementGenerator}.
*
* @param tableName table name to select from.
*/
public CountStarStatementGenerator(final String tableName) {
super(tableName);
}
/**
* Adds where clause predicate.
*
* @param predicate boolean expression that defines where clause
* @return {@code this} for fluent programming
*/
public synchronized CountStarStatementGenerator where(final BooleanExpression predicate) {
if (predicate != null) {
this.select.where(predicate);
}
return this;
}
@Override
public String render() {
this.select.function(COUNT, stringLiteral("*"));
return renderSelect();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy