lincoln-lil commented on code in PR #21641:
URL: https://github.com/apache/flink/pull/21641#discussion_r1095805830
##########
docs/content/docs/dev/table/functions/udfs.md:
##########
@@ -647,15 +647,15 @@ The following system functions are always
non-deterministic(evaluated per record
- RAND_INTEGER
- CURRENT_DATABASE
- UNIX_TIMESTAMP
+- CURRENT_TIMESTAMP
- CURRENT_ROW_TIMESTAMP
+- LOCALTIMESTAMP
+- NOW
Review Comment:
yes, for the runtime implemantation, they all behavior as dynamic functions,
I'll update this
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/expressions/converter/DirectConvertRule.java:
##########
@@ -39,220 +41,281 @@
*/
@Internal
public class DirectConvertRule implements CallExpressionConvertRule {
+ private static Map<Boolean, DirectConvertRule> cachedInstances = new
HashMap<>();
- private static final Map<FunctionDefinition, SqlOperator>
DEFINITION_OPERATOR_MAP =
+ public static synchronized DirectConvertRule instance(boolean isBatchMode)
{
+ DirectConvertRule instance = cachedInstances.get(isBatchMode);
+ if (instance == null) {
+ instance = new DirectConvertRule();
+ instance.init();
+ instance.initDynamicFunctions(isBatchMode);
+ cachedInstances.put(isBatchMode, instance);
+ }
+ return instance;
+ }
+
+ private final Map<FunctionDefinition, SqlOperator>
definitionSqlOperatorHashMap =
new HashMap<>();
- static {
+ void initDynamicFunctions(boolean isBatchMode) {
+ FlinkSqlOperatorTable.dynamicFunctions(isBatchMode)
+ .forEach(
+ func -> {
+ if (func.getName()
+
.equalsIgnoreCase(SqlStdOperatorTable.CURRENT_DATE.getName())) {
+ definitionSqlOperatorHashMap.put(
+
BuiltInFunctionDefinitions.CURRENT_DATE, func);
+ } else if (func.getName()
+
.equalsIgnoreCase(SqlStdOperatorTable.CURRENT_TIME.getName())) {
+ definitionSqlOperatorHashMap.put(
+
BuiltInFunctionDefinitions.CURRENT_TIME, func);
+ } else if (func.getName()
+
.equalsIgnoreCase(SqlStdOperatorTable.LOCALTIME.getName())) {
+ definitionSqlOperatorHashMap.put(
+ BuiltInFunctionDefinitions.LOCAL_TIME,
func);
Review Comment:
This should be done and also for the FlinkSqlOperatorTable, easier for
maintainance
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]