Repository navigation
Add arrayPartialAutocorrelation function - #102160
Draft
wenyuchen96 wants to merge 1 commit into
Draft
wenyuchen96 wants to merge 1 commit into
wenyuchen96 wants to merge 1 commit into
Conversation
arrayPartialAutocorrelation function
arrayPartialAutocorrelation functionarrayPartialAutocorrelation function
Contributor
|
Dear @wenyuchen96, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
Contributor
|
Dear @wenyuchen96, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
pull Bot
pushed a commit
to Mattlk13/ClickHouse
that referenced
this pull request
Aug 17, 2026
arrayAutocorrelation accepts Array(Nothing) deliberately, because [] has that type and arrayAutocorrelation([]) returns []. Both of its ColumnNothing branches guarded on the column type alone, when the correct condition is type and emptiness: ColumnNothing keeps only a row count and holds no readable elements, so a length-N Array(Nothing) like [arrayMax([])] is a structurally valid ColumnArray with zero accessible elements, and this function has no way to represent it. The non-const branch reused the input offsets next to a fresh empty ColumnFloat64, producing offsets=[1] with 0 elements. Since ClickHouse#112504 the ColumnArray constructor rejects that: Logical error: 'offsets_column has data inconsistent with nested_column. Data size: 0, last offset: 1' which is an exception in release builds and an abort in debug and sanitizer builds. The const branch instead zeroed the offsets, so it silently returned [] for any input length. Both branches now reject a non-empty Nothing column with ILLEGAL_COLUMN, using the message already used for this condition in assumeNotNull and in IFunction::defaultImplementationForNothing. The empty case is unchanged. No value is synthesized, because Nothing holds no values and any number produced would be invented. Found by the AST fuzzer (STID 2632-416b). Before ClickHouse#112504 this was a silent wrong result: 26.7.4.15 returns [0]. ClickHouse#112504 is the detector and is correct. arrayPartialAutocorrelation in the open ClickHouse#102160 carries the same defect in both places. Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
|
Workflow [PR], commit [95baaf2] Summary: ❌
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #87209
Relates to: Add arrayAutocorrelation function #94776
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add function
arrayPartialAutocorrelation(arr [, max_lag])that computes the partial autocorrelation of a numeric array for each lag. Supports integer, float, and decimal array types.Documentation entry for user-facing changes
Motivation: Following the addition of the Auto Correlation Function (ACF) in #94776, the Partial Autocorrelation Function (PACF) is the next essential component for in-database time-series analysis. While ACF shows the overall correlation with past lags, PACF isolates the direct correlation between a time series and its lagged values by removing the indirect effects of shorter lags.
This is a critical step for determining the order of Autoregressive (AR) models (like ARIMA) in predictive modeling. Implementing this natively in ClickHouse further eliminates the need to export large datasets to Python or R for standard forecasting and anomaly detection workflows.
Parameters: -
arr: An array of numeric values (Array(Int*)orArray(Float*)). The function automatically casts integers to Float64 for high-precision calculation.max_lag(optional): The maximum lag to compute the partial autocorrelation for.Example use: SELECT arrayPartialAutocorrelation([10, 20, 30, 10, 20, 30]);
Workflow [PR]
Sync PR [sync-upstream/pr/102160]