Skip to content

Commit

Permalink
refactor extra global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Oct 26, 2023
1 parent 91388ef commit 4139e98
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ public interface FlinkSQLConstant {

/** The define identifier of FlinkSQL Variable */
String VARIABLES = ":=";

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,33 @@

package org.dinky.executor;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.expression.engine.jexl.JexlEngine;
import static java.lang.String.format;
import static org.apache.flink.util.Preconditions.checkArgument;
import static org.apache.flink.util.Preconditions.checkNotNull;

import org.dinky.assertion.Asserts;
import org.dinky.constant.FlinkSQLConstant;

import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.TableResult;
import org.apache.flink.table.catalog.exceptions.CatalogException;
import org.apache.flink.types.Row;
import org.apache.flink.util.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.TableResult;
import org.apache.flink.table.catalog.exceptions.CatalogException;
import org.apache.flink.types.Row;
import org.apache.flink.util.StringUtils;
import org.dinky.assertion.Asserts;
import org.dinky.constant.FlinkSQLConstant;
import static java.lang.String.format;
import static org.apache.flink.util.Preconditions.checkArgument;
import static org.apache.flink.util.Preconditions.checkNotNull;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.expression.engine.jexl.JexlEngine;

/**
* Flink Sql Variable Manager
Expand All @@ -65,8 +69,10 @@ public final class VariableManager {
* id -> IdUtil -> to generate random uuid
* ...
*/
public static final Dict ENGINE_CONTEXT = Dict.create().set("random", RandomUtil.class).set("date", DateUtil.class).set("id", IdUtil.class);

public static final Dict ENGINE_CONTEXT = Dict.create()
.set("random", RandomUtil.class)
.set("date", DateUtil.class)
.set("id", IdUtil.class);

public VariableManager() {
variables = new HashMap<>();
Expand Down

0 comments on commit 4139e98

Please sign in to comment.