Skip to content

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

Open
snuyanzin wants to merge 1 commit into
apache:mainfrom
snuyanzin:calcite7567
Open

[CALCITE-7567] LeastRestrictiveSqlType for TIMESTAMP, TIMESTAMP_LTZ might ignore precision#4979
snuyanzin wants to merge 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

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 1, 2026

@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Jun 1, 2026
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.

3 participants