Skip to content

Expose the dtype of a dynamic comparison's value on DynamicComparisonExpr #11550

Open

Description

@wbeckler

Problem or motivation

DynamicComparisonExpr exposes its operator, its default and the current value (scalar()), but not the dtype of the dynamic value. scalar() returns None until a value is known, so code outside vortex-array cannot tell what dtype a dynamic comparison expects.

I ran into this in #11523. The DuckDB converter has to give a dynamic comparison the dtype of the zoned timestamp column it filters. It cannot check whether the comparison already has that dtype, so it rebuilds the comparison for every such column outside UTC, including the ones that table filters built with the right dtype.

Proposed solution

Add an accessor:

impl DynamicComparisonExpr {
    /// The dtype of the dynamic value, whether or not the value is known yet.
    pub fn dtype(&self) -> &DType
}

I will open a pull request with it.

Additional context

Once this and #11523 are both in, the rewrite in vortex-duckdb/src/convert/time_zone.rs can skip a dynamic comparison whose dtype already matches its operand.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions