-
Notifications
You must be signed in to change notification settings - Fork 29
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
register user defined functions #151
Comments
Yes, and that's "normal". It is the reason why the branch |
But I am not using TAP-Lib: how should I register UDF into my program? |
Ok. I did not know. You can find an example on how to declare a UDF with this new version in the directory ADQLLib/examples/, and more precisely: ADQLLib/examples/adql/example/parse/E_DeclareUDF.java |
Let me know if you need more help while waiting for an updated documentation. |
Thanks for the pointer, I played around and I still can't make it work. if I do
I get
whichever I add to the parser, I get the same error. I guess it doesn't like the prefix? For reference, the UDF is:
Am I missing something? |
The prefix you get is perfectly normal. This is the default It seems your UDF is just about a simple translation from ADQL to SQL (no magic thing done in Java before writing the SQL translation). If so, you no longer need to use a // DECLARE A UDF:
// ...get the list of supported features to update:
final FeatureSet features = parser.getSupportedFeatures();
// ...define this function:
FunctionDef myUdf = FunctionDef.parse("ESO_DATEADD_SEC(seconds INTEGER, date TIMESTAMP) -> TIMESTAMP", parser.getADQLVersion());
// ...set a human description (visible in the capabilities of the TAP service):
myUdf.setDescription("Some description");
// ...set (SQL) translation pattern:
myUdf.setTranslationPattern("dateadd(ss, $1, $2)");
// ...now add it to the supported features:
if (!features.support(myUdf.toLanguageFeature()))
throw new Error("Impossible to support the UDF `" + myUdf + "`! This is the important point of this example file."); |
I guess something is indeed missing in your |
I think I don't need
But it still fails. |
No more need to add this to the checker, only to the parser. It actually did not make to set this kind of information in the I hope it does not break too much your code. The honest intent was really to simplify code. |
I managed to make it work the same as before, but I still add to add them to the checker (I'm not actually 100% sure, I changed too many things too many times): if they are not needed there are you going to remove the constructor? |
Maybe. I will see that when I'll adapt TAPLib. |
I am trying to port my TAP server to the adqLib 2.0, and I noticed that it doesn't find the user defined functions.
With adqlLib-1.5 I just added them to the DBChecker.
The text was updated successfully, but these errors were encountered: