Skip to content

[CALCITE-7567] LeastRestrictiveSqlType for TIMESTAMP, TIMESTAMP_LTZ might ignore precision#4979

Merged
snuyanzin merged 1 commit into
apache:mainfrom
snuyanzin:calcite7567
Jun 5, 2026
Merged

[CALCITE-7567] LeastRestrictiveSqlType for TIMESTAMP, TIMESTAMP_LTZ might ignore precision#4979
snuyanzin merged 1 commit into
apache:mainfrom
snuyanzin:calcite7567

Conversation

@snuyanzin
Copy link
Copy Markdown
Contributor

Jira Link

CALCITE-7567

Changes Proposed

The PR makes sure that leastRestrictive for TIMESTAMP(3) and TIMESTAMP_LTZ(0) will return result with same precision as for TIMESTAMP_LTZ(0) and TIMESTAMP_LTZ(3)

}

if (type.getSqlTypeName() == resultType.getSqlTypeName()
if (type.getSqlTypeName().getFamily() == resultType.getSqlTypeName().getFamily()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may affect many more types than just TIMESTAMPs.

Copy link
Copy Markdown
Contributor Author

@snuyanzin snuyanzin May 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate on this please?
Asking since we are already inside this condition here

      } else if (SqlTypeUtil.isDatetime(type)) {
         ...
      }

https://github.com/snuyanzin/calcite/blob/16c2b1c3469f504bc540c9f12438778e2ca7b2d7/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFactoryImpl.java#L550

@julianhyde
Copy link
Copy Markdown
Contributor

There's a typo in the subject.

@snuyanzin snuyanzin changed the title [CALCITE-7567] LeastRetrictiveSqlType for TIMESTAMP, TIMESTAMP_LTZ might ignore precision [CALCITE-7567] LeastRestrictiveSqlType for TIMESTAMP, TIMESTAMP_LTZ might ignore precision Jun 1, 2026
@snuyanzin
Copy link
Copy Markdown
Contributor Author

Thanks,
fixed the typo and rebased

@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Jun 1, 2026
@snuyanzin
Copy link
Copy Markdown
Contributor Author

rebase to recent main before merging

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 5, 2026

@snuyanzin snuyanzin merged commit 2f62681 into apache:main Jun 5, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM-will-merge-soon Overall PR looks OK. Only minor things left.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants