From 345b4759cc13bcf0d2c7f5b5f0e66d02e7bdba16 Mon Sep 17 00:00:00 2001 From: "lgbo.ustc" Date: Fri, 30 May 2025 14:30:13 +0800 Subject: [PATCH] Register prestosql scalar functions --- src/main/cpp/main/velox4j/init/Init.cc | 2 ++ .../connector/DiscardDataTableHandle.java | 16 ++++++++++ .../connector/FuzzerConnectorSplit.java | 20 ++++++++++-- .../velox4j/connector/FuzzerTableHandle.java | 20 ++++++++++-- .../velox4j/connector/InsertTableHandle.java | 4 +-- .../connector/NexmarkConnectorSplit.java | 20 ++++++++++-- .../velox4j/connector/NexmarkTableHandle.java | 20 ++++++++++-- .../zhztheplayer/velox4j/plan/FilterNode.java | 2 +- .../zhztheplayer/velox4j/plan/PlanNode.java | 1 + .../velox4j/plan/ProjectNode.java | 2 +- .../velox4j/plan/TableWriteNode.java | 2 +- .../velox4j/plan/WatermarkAssignerNode.java | 32 ++++++++++++++----- .../velox4j/serde/NativeBean.java | 3 +- 13 files changed, 117 insertions(+), 27 deletions(-) diff --git a/src/main/cpp/main/velox4j/init/Init.cc b/src/main/cpp/main/velox4j/init/Init.cc index a56efae515..bc081d7b28 100644 --- a/src/main/cpp/main/velox4j/init/Init.cc +++ b/src/main/cpp/main/velox4j/init/Init.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,7 @@ void initForSpark() { parquet::registerParquetReaderFactory(); parquet::registerParquetWriterFactory(); functions::sparksql::registerFunctions(); + functions::prestosql::registerAllScalarFunctions(); aggregate::prestosql::registerAllAggregateFunctions( "", true /*registerCompanionFunctions*/, diff --git a/src/main/java/io/github/zhztheplayer/velox4j/connector/DiscardDataTableHandle.java b/src/main/java/io/github/zhztheplayer/velox4j/connector/DiscardDataTableHandle.java index c6f6044edd..2f649e0fbb 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/connector/DiscardDataTableHandle.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/connector/DiscardDataTableHandle.java @@ -1,3 +1,19 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package io.github.zhztheplayer.velox4j.connector; import com.fasterxml.jackson.annotation.JsonCreator; diff --git a/src/main/java/io/github/zhztheplayer/velox4j/connector/FuzzerConnectorSplit.java b/src/main/java/io/github/zhztheplayer/velox4j/connector/FuzzerConnectorSplit.java index d6dd4d513b..b197ddd2b0 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/connector/FuzzerConnectorSplit.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/connector/FuzzerConnectorSplit.java @@ -1,3 +1,19 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package io.github.zhztheplayer.velox4j.connector; import com.fasterxml.jackson.annotation.JsonCreator; @@ -10,8 +26,7 @@ public class FuzzerConnectorSplit extends ConnectorSplit { @JsonCreator public FuzzerConnectorSplit( - @JsonProperty("connectorId") String connectorId, - @JsonProperty("numRows") int numRows) { + @JsonProperty("connectorId") String connectorId, @JsonProperty("numRows") int numRows) { super(connectorId, 0, true); this.numRows = numRows; } @@ -30,5 +45,4 @@ public boolean isCacheable() { public int getNumRows() { return numRows; } - } diff --git a/src/main/java/io/github/zhztheplayer/velox4j/connector/FuzzerTableHandle.java b/src/main/java/io/github/zhztheplayer/velox4j/connector/FuzzerTableHandle.java index b865a76f8c..be1f1eb410 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/connector/FuzzerTableHandle.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/connector/FuzzerTableHandle.java @@ -1,3 +1,19 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package io.github.zhztheplayer.velox4j.connector; import com.fasterxml.jackson.annotation.JsonCreator; @@ -9,8 +25,7 @@ public class FuzzerTableHandle extends ConnectorTableHandle { @JsonCreator public FuzzerTableHandle( - @JsonProperty("connectorId") String connectorId, - @JsonProperty("fuzzerSeed") int fuzzerSeed) { + @JsonProperty("connectorId") String connectorId, @JsonProperty("fuzzerSeed") int fuzzerSeed) { super(connectorId); this.fuzzerSeed = fuzzerSeed; } @@ -19,5 +34,4 @@ public FuzzerTableHandle( public int getSeed() { return fuzzerSeed; } - } diff --git a/src/main/java/io/github/zhztheplayer/velox4j/connector/InsertTableHandle.java b/src/main/java/io/github/zhztheplayer/velox4j/connector/InsertTableHandle.java index eec7d113fb..ff24019ba0 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/connector/InsertTableHandle.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/connector/InsertTableHandle.java @@ -16,12 +16,12 @@ */ package io.github.zhztheplayer.velox4j.connector; +import java.io.Serializable; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; - public class InsertTableHandle implements Serializable { private final String connectorId; private final ConnectorInsertTableHandle connectorInsertTableHandle; diff --git a/src/main/java/io/github/zhztheplayer/velox4j/connector/NexmarkConnectorSplit.java b/src/main/java/io/github/zhztheplayer/velox4j/connector/NexmarkConnectorSplit.java index 4a1e2d37fc..161ac56dd0 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/connector/NexmarkConnectorSplit.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/connector/NexmarkConnectorSplit.java @@ -1,3 +1,19 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package io.github.zhztheplayer.velox4j.connector; import com.fasterxml.jackson.annotation.JsonCreator; @@ -10,8 +26,7 @@ public class NexmarkConnectorSplit extends ConnectorSplit { @JsonCreator public NexmarkConnectorSplit( - @JsonProperty("connectorId") String connectorId, - @JsonProperty("numRows") int numRows) { + @JsonProperty("connectorId") String connectorId, @JsonProperty("numRows") int numRows) { super(connectorId, 0, true); this.numRows = numRows; } @@ -20,5 +35,4 @@ public NexmarkConnectorSplit( public int getNumRows() { return numRows; } - } diff --git a/src/main/java/io/github/zhztheplayer/velox4j/connector/NexmarkTableHandle.java b/src/main/java/io/github/zhztheplayer/velox4j/connector/NexmarkTableHandle.java index 521c92365e..d050dc69cd 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/connector/NexmarkTableHandle.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/connector/NexmarkTableHandle.java @@ -1,3 +1,19 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package io.github.zhztheplayer.velox4j.connector; import com.fasterxml.jackson.annotation.JsonCreator; @@ -6,9 +22,7 @@ public class NexmarkTableHandle extends ConnectorTableHandle { @JsonCreator - public NexmarkTableHandle( - @JsonProperty("connectorId") String connectorId) { + public NexmarkTableHandle(@JsonProperty("connectorId") String connectorId) { super(connectorId); } - } diff --git a/src/main/java/io/github/zhztheplayer/velox4j/plan/FilterNode.java b/src/main/java/io/github/zhztheplayer/velox4j/plan/FilterNode.java index 56ec3fccb6..fe556cee6c 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/plan/FilterNode.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/plan/FilterNode.java @@ -18,10 +18,10 @@ import java.util.List; -import com.google.common.base.Preconditions; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Preconditions; import io.github.zhztheplayer.velox4j.expression.TypedExpr; diff --git a/src/main/java/io/github/zhztheplayer/velox4j/plan/PlanNode.java b/src/main/java/io/github/zhztheplayer/velox4j/plan/PlanNode.java index 3bbc72381f..bd11269a06 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/plan/PlanNode.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/plan/PlanNode.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonInclude; + import io.github.zhztheplayer.velox4j.exception.VeloxException; import io.github.zhztheplayer.velox4j.serializable.ISerializable; diff --git a/src/main/java/io/github/zhztheplayer/velox4j/plan/ProjectNode.java b/src/main/java/io/github/zhztheplayer/velox4j/plan/ProjectNode.java index bc5b188d22..a9d41ee469 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/plan/ProjectNode.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/plan/ProjectNode.java @@ -18,10 +18,10 @@ import java.util.List; -import com.google.common.base.Preconditions; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Preconditions; import io.github.zhztheplayer.velox4j.expression.TypedExpr; diff --git a/src/main/java/io/github/zhztheplayer/velox4j/plan/TableWriteNode.java b/src/main/java/io/github/zhztheplayer/velox4j/plan/TableWriteNode.java index 102c2cdb03..d8bafdc4fc 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/plan/TableWriteNode.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/plan/TableWriteNode.java @@ -18,10 +18,10 @@ import java.util.List; -import com.google.common.base.Preconditions; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Preconditions; import io.github.zhztheplayer.velox4j.connector.CommitStrategy; import io.github.zhztheplayer.velox4j.connector.ConnectorInsertTableHandle; diff --git a/src/main/java/io/github/zhztheplayer/velox4j/plan/WatermarkAssignerNode.java b/src/main/java/io/github/zhztheplayer/velox4j/plan/WatermarkAssignerNode.java index 2ee8a7d1c4..258a29062a 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/plan/WatermarkAssignerNode.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/plan/WatermarkAssignerNode.java @@ -1,11 +1,27 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package io.github.zhztheplayer.velox4j.plan; -import com.google.common.base.Preconditions; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; +import com.google.common.base.Preconditions; public class WatermarkAssignerNode extends PlanNode { private List sources; @@ -15,11 +31,11 @@ public class WatermarkAssignerNode extends PlanNode { @JsonCreator public WatermarkAssignerNode( - @JsonProperty("id") String id, - @JsonProperty("sources") List sources, - @JsonProperty("project") ProjectNode project, - @JsonProperty("idleTimeout") long idleTimeout, - @JsonProperty("rowtimeFieldIndex") int rowtimeFieldIndex) { + @JsonProperty("id") String id, + @JsonProperty("sources") List sources, + @JsonProperty("project") ProjectNode project, + @JsonProperty("idleTimeout") long idleTimeout, + @JsonProperty("rowtimeFieldIndex") int rowtimeFieldIndex) { super(id); this.sources = sources; this.project = project; diff --git a/src/main/java/io/github/zhztheplayer/velox4j/serde/NativeBean.java b/src/main/java/io/github/zhztheplayer/velox4j/serde/NativeBean.java index 511c385aef..ce91dcefdc 100644 --- a/src/main/java/io/github/zhztheplayer/velox4j/serde/NativeBean.java +++ b/src/main/java/io/github/zhztheplayer/velox4j/serde/NativeBean.java @@ -18,5 +18,4 @@ import java.io.Serializable; -public interface NativeBean extends Serializable { -} +public interface NativeBean extends Serializable {}