Class ColumnProfiler
ColumnProfilerRunner producing JSON wire-compatible with
Deequ 2.0.7-spark-3.5 for all keys except kll.
KLL gating divergence from Deequ
Deequ always emits kll for numeric columns regardless of withKLLProfiling();
the toggle is a no-op in 2.0.7-spark-3.5.
This implementation emits kll only when kll=true, aligning with the Phase-1
API contract.
The kll=false path produces smaller profiles.
The golden-parity test (task #6) accounts for this known divergence.
Entropy computation
Shannon entropy is derived from the exact per-value frequency distribution via
groupBy(col).count() per column.
For numeric columns where all values are unique this equals
ln(exactNumDistinctValues), but the groupBy is required for correctness when
duplicates exist.
Uniqueness formula
uniqueness = singletons / nonNull: Deequ's exact definition (fraction of values
appearing exactly once).
The singleton count comes from the same per-value frequency pass as entropy, so no
additional Spark job is paid for it.
(An earlier shortcut, (2 * exactDistinct - nonNull) / nonNull, is only equivalent
when no value occurs more than twice and undercounts otherwise.)
stdDev
Uses Spark's stddev_pop() (population standard deviation, dividing by n).
Deequ's StandardDeviation metric also uses population stddev; verified against the baseline.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprofile(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> df, List<String> restrictToColumns, boolean correlation, boolean histogram, int histogramBins, boolean exactUniqueness, boolean kll) Profiles the given dataframe and returns a JSON string matching the Deequ wire format.
-
Constructor Details
-
ColumnProfiler
public ColumnProfiler()
-
-
Method Details
-
profile
public String profile(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> df, List<String> restrictToColumns, boolean correlation, boolean histogram, int histogramBins, boolean exactUniqueness, boolean kll) Profiles the given dataframe and returns a JSON string matching the Deequ wire format.- Parameters:
df- source dataframerestrictToColumns- columns to profile; null or empty means all columnscorrelation- whether to compute pairwise Pearson correlations for numeric columnshistogram- whether to compute histogram binshistogramBins- number of histogram bins (used only when histogram=true)exactUniqueness- whether to compute exact distinct counts via countDistinctkll- whether to compute KLL sketches and derived percentiles for numeric columns- Returns:
- JSON string with top-level
{"columns": [...]}
-