Skip to content
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

SQL function availability depends on runtime context #1168

Closed
bratseth opened this issue Jun 30, 2021 · 1 comment · Fixed by #1172
Closed

SQL function availability depends on runtime context #1168

bratseth opened this issue Jun 30, 2021 · 1 comment · Fixed by #1172

Comments

@bratseth
Copy link
Contributor

Describe the bug

I'm trying to evaluate this statement:

alter table metrics drop partition where at < dateadd('d', -4, now());

It works as expected when running it locally (regardless of OS), but when it runs on our production servers it fails with

io.questdb.griffin.SqlException: [70] unknown function name: now()
at io.questdb.griffin.SqlException.position(SqlException.java:60)
at io.questdb.griffin.FunctionParser.invalidFunction(FunctionParser.java:295)
at io.questdb.griffin.FunctionParser.createFunction(FunctionParser.java:465)
at io.questdb.griffin.FunctionParser.visit(FunctionParser.java:277)
at io.questdb.griffin.PostOrderTreeTraversalAlgo.traverse(PostOrderTreeTraversalAlgo.java:82)
at io.questdb.griffin.FunctionParser.parseFunction(FunctionParser.java:230)
at io.questdb.griffin.SqlCompiler.alterTableDropOrAttachPartition(SqlCompiler.java:1094)
at io.questdb.griffin.SqlCompiler.alterTable(SqlCompiler.java:769)

The only relevant difference between these runtime environments is that on the production servers QuestDB is loaded as part of an OSGi bundle. This means that it will have a special classloader and will not find its classes using the system classloader.

Is QuestDb loading functions through some classloader introspection or assumptions about the system classloader? If so I can probably provide a fix for you if you point me in the right direction.

If not, can you think of any other reason for this?

@bluestreak01
Copy link
Member

hey Jon,

We load functions using java.util.ServiceLoader. Call literally looks like:

ServiceLoader.load(FunctionFactory.class)

We found that on Java11 functions are loaded from module-info.java, but on Java8 from META-INF/services/. OSGi might offer something else entirely.

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 a pull request may close this issue.

2 participants