You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add model validation to verify DbFunction's parameter types are mapped #13782
See example in #13752. If I try to use this function, which is defined correctly but doesn't work, then all I get is the NotImplementedException. I get no info as to what happened that causes it not to be used.
Triage: Discussed this as a case where we might want to change when/if we drop down to client evaluation. Most cases where a DbFunction mapping is being made it is because there is a desire to translate it to SQL. Not giving feedback when a use of the mapping cannot be translated doesn't help people find what they are doing wrong. We could, for example, detect in model validation some cases where we will never translate.
There are two reasons a DbFunction won't translate. The first, as you found, is the inability to map a type for one of the parameters. The second reason is if the parameter is itself a function call which is not translatable. This can be because one of it's parameter types can't be mapped or it isn't a translatable function (DbFunction or builtin)
You then end up having to go down the recursive rabbit hole until you work your way through all of the nested functions.
I already have a set of unit tests defined in UdfDbFunctionSqlServerTests which test the various nesting/client eval scenarios and make sure translation is handled correctly. These all start with "Scalar_Nested_Function_". These can be leveraged and expanded to check for the warning messages once they are added.
changed the title [-]Allow configuring typemapping of UDF parameters[/-][+]Add model validation to verify DbFunction's parameter types are mapped[/+]on Jan 16, 2019
Activity
ajcvickers commentedon Oct 29, 2018
Triage: Discussed this as a case where we might want to change when/if we drop down to client evaluation. Most cases where a DbFunction mapping is being made it is because there is a desire to translate it to SQL. Not giving feedback when a use of the mapping cannot be translated doesn't help people find what they are doing wrong. We could, for example, detect in model validation some cases where we will never translate.
pmiddleton commentedon Oct 30, 2018
There are two reasons a DbFunction won't translate. The first, as you found, is the inability to map a type for one of the parameters. The second reason is if the parameter is itself a function call which is not translatable. This can be because one of it's parameter types can't be mapped or it isn't a translatable function (DbFunction or builtin)
You then end up having to go down the recursive rabbit hole until you work your way through all of the nested functions.
I already have a set of unit tests defined in UdfDbFunctionSqlServerTests which test the various nesting/client eval scenarios and make sure translation is handled correctly. These all start with "Scalar_Nested_Function_". These can be leveraged and expanded to check for the warning messages once they are added.
[-]No indication of why a function mapping is not used[/-][+]Allow configuring facets of UDF parameters[/+][-]Allow configuring facets of UDF parameters[/-][+]Allow configuring typemapping of UDF parameters[/+][-]Allow configuring typemapping of UDF parameters[/-][+]Add model validation to verify DbFunction's parameter types are mapped[/+]8 remaining items
Add DbFunctionParameter support for DbFunctions
Add DbFunctionParameter support for DbFunctions
Add DbFunctionParameter support for DbFunctions