Skip to content

Zero-time aggregate output turns into current-date midnight after view materialization. #161

Description

@123lpygithub

Under SQL-equivalent rewriting, the source and mutated queries differ only in extracting MIN(c5) into a projection view. The first row changes from zero datetime to the current date at midnight.

version: 8.0.44-alisql-dev

How to repeat:

DROP VIEW IF EXISTS v;
DROP TABLE IF EXISTS t3;

CREATE TABLE t3 (
  c5 TIME
);

INSERT INTO t3 VALUES ('00:00:00');

-- Original SQL
SELECT MIN(c5)
FROM t3
UNION ALL
SELECT DATE('2001-01-01');

-- View SQL
CREATE VIEW v AS
SELECT MIN(c5)
FROM t3;

-- Mutated SQL
SELECT *
FROM v
UNION ALL
SELECT DATE('2001-01-01');

Observed mismatch:

  • original result:
MIN(c5)
0000-00-00 00:00:00
2001-01-01 00:00:00
  • mutated result on 2026-06-30:
MIN(c5)
2026-06-30 00:00:00
2001-01-01 00:00:00

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions