I am trying to make an external API call using my UDF and send a part of the response to the query, I have seen some posts here wherein it was in discussion but it didn’t lead to anything.
I am using tigergraph in docker and i have found a CPP library httplib which could make API calls but when i try to put the headerfile in the place where ExprFunctions.hpp is located and calling it in ExprFunctions.hpp, it throws alot of errors. Some of the errors are shown here.
Is there any definite way to achieve this feature? Any help on this would be appreciated.
ps. I didn’t define any function, rather just used #include<httplib.h>
What you’re doing sounds pretty standard for UDFs, and since the library appears to be C++11 compliant, it’s not clear why you’re having a problem. Could you please show us the point in the log where the first compiler error appears and also the contents of your ExprFunctions.hpp?
here is where the error started. You can see the arrow.
and this error comes quite a few times
here is the ExprFunctions.hpp
The underlined line is where I include httplib.h
Any help would be appreciated.
Had to try it myself. I hope I’m not giving you too basic of a lecture here, but in general, the very first compiler error, not warning, is your best clue about what went wrong. If there is an error in a statement, the compiler often just drops the statement. Any statements afterwards that depend on the dropped statement will also have a problem, as you’re seeing.
The first error is actually this one, and it is the key to solving the problem:
E@20220413 12:19:41.138 dliddell|127.0.0.1:41124|00000000183 (ExternalUtil.java:530) /proj/gdba/dliddell/Projects/cpp-httplib/httplib.h: In function ‘const char* httplib::detail::find_content_type(const string&, const std::map<std::basic_string, std::basic_string >&)’:
E@20220413 12:19:41.138 dliddell|127.0.0.1:41124|00000000183 (ExternalUtil.java:530) /proj/gdba/dliddell/Projects/cpp-httplib/httplib.h:2810:14: error: missing space between ‘""’ and suffix identifier
Apparently, old versions of GCC, which includes the one TigerGraph uses, require a space between
operator"" and the suffix. This bug report for cpp-httplib explains:
Fix: using udl::operator "" _ by x4t3a · Pull Request #865 · yhirose/cpp-httplib · GitHub.
It doesn’t appear that the owner of the library has made this fix, as it has been complained about several times. You can fix it yourself by putting in the space. I found two places where it needs to be done, on lines 2810 and 2937. After I made those fixes, the compilation went through.
Thanks for helping out, Dave!