Skip to content

Add support for EXTRACT function in Postgres v14 Upgrade #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yaojiejia
Copy link
Contributor

Closes #1242

@mrigger
Copy link
Contributor

mrigger commented Jun 17, 2025

Sorry for the delay in reviewing. I have been traveling and did not see this PR.

It seems given that EXTRACT has a special syntax, and the current implementation introduces some additional checks at multiple places to deal with them. I think this is not ideal in terms of OOP. Would it be possible to have a special subclass and implement the variability in methods that are overwritten?

@yaojiejia
Copy link
Contributor Author

Sorry for the delay in reviewing. I have been traveling and did not see this PR.

It seems given that EXTRACT has a special syntax, and the current implementation introduces some additional checks at multiple places to deal with them. I think this is not ideal in terms of OOP. Would it be possible to have a special subclass and implement the variability in methods that are overwritten?

Sounds good, just made some changes about that

sb.append(", ");
}

if (args[i].getExpressionType() == PostgresDataType.TIME
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this logic necessary? I don't really understand, so perhaps extracting this to a method that explains its purpose would be helpful.

PostgresExpression[] args = randomFunction.getArguments(type, this, depth + 1);

// Create the appropriate function type based on the function name
if (randomFunction.getName().equals("extract")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we reference the enum here? Checking for hard-coded strings like extract is a somewhat error-prone pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PostgreSQL Version 14 Upgrade - Supporting EXTRACT() Function
2 participants