julianhyde commented on a change in pull request #973: [CALCITE-2742] Update
USER and SYSTEM_USER to use DataContext for value
URL: https://github.com/apache/calcite/pull/973#discussion_r287167196
##########
File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
##########
@@ -1951,6 +1952,20 @@ public static TimeZone timeZone(DataContext root) {
return (TimeZone) DataContext.Variable.TIME_ZONE.get(root);
}
+ /** SQL {@code USER} function. */
+ @NonDeterministic
+ public static String user(DataContext root) {
+ return Optional.ofNullable((String) DataContext.Variable.USER.get(root))
+ .orElse("sa");
+ }
+
+ /** SQL {@code SYSTEM_USER} function. */
+ @NonDeterministic
Review comment:
Conceivably (I know it's a stretch) a query could be prepared by one user
and executed by another. The NonDeterministic prevents constant-reduction.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services