So playing around with this, I realized that this is a problem specific to 
functions that return "object" types. So it applies only for META, ANY_META 
& ENTRY_META, and, with my changes, COALESCE(). The return values can be 
casted with STR() where required and I can make COALESCE() a bit smarter. 
If the arguments of COALESCE() are the same, then that is obviously the 
return type!

Anyway, sorry for the spam on the mailing list about this. This might not 
really be an issue at all!

- Shreedhar


On Sunday, November 18, 2018 at 4:01:56 PM UTC-6, [email protected] 
wrote:
>
> Hi, 
>
> This issue showed up when I was writing tests for SUB() function for 
> bean-query. The function/query dispatch mechanism doesn't like nested 
> functions if the function arguments are declared as typed.
>
> The error:
> beancount>  select meta(meta('t'))
> ERROR: Invalid type for argument 0 of Meta: found <class 'object'> 
> expected <class 'str'>.
>
> The error comes from EvalFunctions.__init__():
>
>
>         # Check each of the types.
>         for index, (operand, intype) in enumerate(zip(operands, 
> self.__intypes__)):
>             if not issubclass(operand.dtype, intype):
>                 raise CompilationError(
>                     "Invalid type for argument {} of {}: found {} expected 
> {}".format(
>                         index, type(self).__name__, operand.dtype, intype))
>
>
>
> Perhaps this can be extended to include other EvalFunctions ? I took a 
> shot at that and it seems to work for the given query. It's not extensively 
> tested, but the tests under query passed.
>
>
> PR: https://bitbucket.org/blais/beancount/pull-requests/88.
>
>
> Let me know what you think. I can then add more tests - the only thing is 
> that I'm not sure exactly where to add them.
>
>
> Thanks!
>
> - Shreedhar
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/922d85e7-9d2e-4f0f-a880-85f62616654d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to