diff --git a/logictests/date_params.test b/logictests/date_params.test new file mode 100644 index 0000000000..6b0b9a76ca --- /dev/null +++ b/logictests/date_params.test @@ -0,0 +1,18 @@ +statement ok +CREATE TABLE `table_1` (`column_2` INT, `column_1` DATE, PRIMARY KEY (`column_2`)) + + +statement ok +INSERT INTO `table_1` (`column_2`, `column_1`) VALUES (0, '2020-01-01') + +onlyif readyset +statement ok +create cache from SELECT dayofweek(`table_1`.`column_1`) AS `alias_1` FROM `table_1` WHERE (`table_1`.`column_1` = ?) + +graphviz + +query rowsort +SELECT count(*) AS `alias_1` FROM `table_1` WHERE (`table_1`.`column_1` = ?) +? = 2020-01-01 00:00:00 +---- +1 diff --git a/readyset-data/src/timestamp.rs b/readyset-data/src/timestamp.rs index 44633d39e4..da894d0e85 100644 --- a/readyset-data/src/timestamp.rs +++ b/readyset-data/src/timestamp.rs @@ -39,7 +39,7 @@ pub const DATE_FORMAT: &str = "%Y-%m-%d"; /// /// Sadly the way chrono implements `DateTime` occupies at least 16 bytes, and therefore /// overflows DfValue. So this type internally stores a [`NaiveDateTime`] with a 3 byte -/// of extra data. Since 3 bytes allow us to store 24 bytes, this is how we use them: +/// of extra data. Since 3 bytes allow us to store 24 bits, this is how we use them: /// /// 17 bits for the timezone offset (0 to 86_400) /// 1 bit to signify negative offset @@ -350,7 +350,11 @@ impl TimestampTz { ts.set_subsecond_digits(subsecond_digits as u8); Ok(DfValue::TimestampTz(ts)) } - DfType::Date => Ok(DfValue::TimestampTz(self.to_chrono().date().into())), + DfType::Date => Ok(if self.has_timezone() { + DfValue::TimestampTz(self.to_chrono().date().into()) + } else { + DfValue::TimestampTz(self.to_chrono().date_naive().into()) + }), // TODO(ENG-1833): Use `subsecond_digits` value. DfType::Time { .. } => Ok(self.to_chrono().naive_local().time().into()),