[GitHub] siddharthteotia commented on a change in pull request #1031: [CALCITE-2742]: Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER

2019-02-28 Thread GitBox
siddharthteotia commented on a change in pull request #1031: [CALCITE-2742]: 
Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER
URL: https://github.com/apache/calcite/pull/1031#discussion_r261386852
 
 

 ##
 File path: core/src/test/java/org/apache/calcite/rex/RexExecutorTest.java
 ##
 @@ -175,6 +177,58 @@ private void checkConstant(final Object operand,
 });
   }
 
+  @Test public void testUserFromContext() throws Exception {
+testContextLiteral(SqlStdOperatorTable.USER,
+   DataContext.Variable.USER, "happyCalciteUser");
+  }
+
+  @Test public void testSystemUserFromContext() throws Exception {
+testContextLiteral(SqlStdOperatorTable.SYSTEM_USER,
+   DataContext.Variable.SYSTEM_USER, "");
+  }
+
+  @Test public void testTimestampFromContext() throws Exception {
+// current timestamp currently rounds to the nearest second (?)
+long val = System.currentTimeMillis() / 1000 * 1000;
+testContextLiteral(SqlStdOperatorTable.CURRENT_TIMESTAMP,
+   DataContext.Variable.CURRENT_TIMESTAMP, val);
+  }
 
 Review comment:
   How can we address this?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] siddharthteotia commented on a change in pull request #1031: CALCITE-2742: Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER

2019-02-28 Thread GitBox
siddharthteotia commented on a change in pull request #1031: CALCITE-2742: 
Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER
URL: https://github.com/apache/calcite/pull/1031#discussion_r261378419
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
 ##
 @@ -1966,6 +1967,20 @@ public static TimeZone timeZone(DataContext root) {
 return (TimeZone) DataContext.Variable.TIME_ZONE.get(root);
   }
 
+  /** SQL {@code USER} function. */
+  @NonDeterministic
 
 Review comment:
   Thanks. Yes this should be deterministic. It was initially non-deterministic 
 to be consistent with other functions in the class 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] siddharthteotia commented on a change in pull request #1031: CALCITE-2742: Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER

2019-02-28 Thread GitBox
siddharthteotia commented on a change in pull request #1031: CALCITE-2742: 
Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER
URL: https://github.com/apache/calcite/pull/1031#discussion_r261378619
 
 

 ##
 File path: core/src/test/java/org/apache/calcite/rex/RexExecutorTest.java
 ##
 @@ -175,6 +177,58 @@ private void checkConstant(final Object operand,
 });
   }
 
+  @Test public void testUserFromContext() throws Exception {
+testContextLiteral(SqlStdOperatorTable.USER,
+   DataContext.Variable.USER, "happyCalciteUser");
+  }
 
 Review comment:
   done.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] siddharthteotia commented on a change in pull request #1031: CALCITE-2742: Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER

2019-02-28 Thread GitBox
siddharthteotia commented on a change in pull request #1031: CALCITE-2742: 
Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER
URL: https://github.com/apache/calcite/pull/1031#discussion_r261378419
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
 ##
 @@ -1966,6 +1967,20 @@ public static TimeZone timeZone(DataContext root) {
 return (TimeZone) DataContext.Variable.TIME_ZONE.get(root);
   }
 
+  /** SQL {@code USER} function. */
+  @NonDeterministic
 
 Review comment:
   Thanks. Yes this should be deterministic. It was done to be consistent with 
other functions in the class 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] siddharthteotia commented on a change in pull request #1031: CALCITE-2742: Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER

2019-02-28 Thread GitBox
siddharthteotia commented on a change in pull request #1031: CALCITE-2742: 
Update RexImpTable to use DataContext to retrieve USER and SYSTEM_USER
URL: https://github.com/apache/calcite/pull/1031#discussion_r261378248
 
 

 ##
 File path: core/src/test/java/org/apache/calcite/rex/RexExecutorTest.java
 ##
 @@ -175,6 +177,58 @@ private void checkConstant(final Object operand,
 });
   }
 
+  @Test public void testUserFromContext() throws Exception {
+testContextLiteral(SqlStdOperatorTable.USER,
+   DataContext.Variable.USER, "happyCalciteUser");
+  }
+
+  @Test public void testSystemUserFromContext() throws Exception {
+testContextLiteral(SqlStdOperatorTable.SYSTEM_USER,
+   DataContext.Variable.SYSTEM_USER, "");
+  }
+
+  @Test public void testTimestampFromContext() throws Exception {
+// current timestamp currently rounds to the nearest second (?)
+long val = System.currentTimeMillis() / 1000 * 1000;
+testContextLiteral(SqlStdOperatorTable.CURRENT_TIMESTAMP,
+   DataContext.Variable.CURRENT_TIMESTAMP, val);
+  }
+
+  /**
+   * Ensure that for a given context operator, the correct value is retrieved 
from the DataContext.
 
 Review comment:
   done.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services