You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/08/11 07:55:30 UTC
[GitHub] [flink] liuyongvs opened a new pull request, #20546: [FLINK-28919][table] Add built-in generate_series function.
liuyongvs opened a new pull request, #20546:
URL: https://github.com/apache/flink/pull/20546
## What is the purpose of the change
*Add built-in generate_series function.*
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] liuyongvs closed pull request #20546: [FLINK-28919][table] Add built-in generate_series function.
Posted by GitBox <gi...@apache.org>.
liuyongvs closed pull request #20546: [FLINK-28919][table] Add built-in generate_series function.
URL: https://github.com/apache/flink/pull/20546
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] snuyanzin commented on a diff in pull request #20546: [FLINK-28919][table] Add built-in generate_series function.
Posted by GitBox <gi...@apache.org>.
snuyanzin commented on code in PR #20546:
URL: https://github.com/apache/flink/pull/20546#discussion_r948708082
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/table/GenerateSeriesFunction.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 org.apache.flink.table.runtime.functions.table;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.table.functions.SpecializedFunction.SpecializedContext;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.utils.LogicalTypeMerging;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * GenerateSeries implements the table function `generate_series(start, stop)`
+ * `generate_series(start, * stop, step)` which generate a series of values, from start to stop with
+ * a step size.
+ */
+@Internal
+public class GenerateSeriesFunction extends BuiltInTableFunction<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final transient DataType outputDataType;
+ private final LogicalType outputLogicalType;
+
+ public GenerateSeriesFunction(SpecializedContext specializedContext) {
+ super(BuiltInFunctionDefinitions.GENERATE_SERIES, specializedContext);
+
+ // The output type in the context is already wrapped, however, the result of the
+ // function is not. Therefore, we need a custom output type.
+ final List<LogicalType> actualTypes =
+ specializedContext.getCallContext().getArgumentDataTypes().stream()
+ .map(DataType::getLogicalType)
+ .collect(Collectors.toList());
+ this.outputLogicalType = LogicalTypeMerging.findCommonType(actualTypes).get();
+ this.outputDataType = DataTypes.of(outputLogicalType).toInternal();
+ }
+
+ @Override
+ public DataType getOutputDataType() {
+ return outputDataType;
+ }
+
+ public void eval(Number start, Number stop) {
+ eval(start, stop, 1);
+ }
+
+ public void eval(Number start, Number stop, Number step) {
+ if (isZero(step.doubleValue(), 0.000001)) {
Review Comment:
How was this threshold chosen?
do mysql/postgres behave in the same manner?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] snuyanzin commented on a diff in pull request #20546: [FLINK-28919][table] Add built-in generate_series function.
Posted by GitBox <gi...@apache.org>.
snuyanzin commented on code in PR #20546:
URL: https://github.com/apache/flink/pull/20546#discussion_r948706751
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/table/GenerateSeriesFunction.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 org.apache.flink.table.runtime.functions.table;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.table.functions.SpecializedFunction.SpecializedContext;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.utils.LogicalTypeMerging;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * GenerateSeries implements the table function `generate_series(start, stop)`
+ * `generate_series(start, * stop, step)` which generate a series of values, from start to stop with
+ * a step size.
+ */
+@Internal
+public class GenerateSeriesFunction extends BuiltInTableFunction<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final transient DataType outputDataType;
+ private final LogicalType outputLogicalType;
+
+ public GenerateSeriesFunction(SpecializedContext specializedContext) {
+ super(BuiltInFunctionDefinitions.GENERATE_SERIES, specializedContext);
+
+ // The output type in the context is already wrapped, however, the result of the
+ // function is not. Therefore, we need a custom output type.
+ final List<LogicalType> actualTypes =
+ specializedContext.getCallContext().getArgumentDataTypes().stream()
+ .map(DataType::getLogicalType)
+ .collect(Collectors.toList());
+ this.outputLogicalType = LogicalTypeMerging.findCommonType(actualTypes).get();
+ this.outputDataType = DataTypes.of(outputLogicalType).toInternal();
+ }
+
+ @Override
+ public DataType getOutputDataType() {
+ return outputDataType;
+ }
+
+ public void eval(Number start, Number stop) {
+ eval(start, stop, 1);
+ }
+
+ public void eval(Number start, Number stop, Number step) {
+ if (isZero(step.doubleValue(), 0.000001)) {
+ throw new IllegalArgumentException("step size cannot equal zero");
+ }
+
+ double s = start.doubleValue();
Review Comment:
Could we expect here `BigDecimal`/`DECIMAL` and if yes how will it wokr?
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/table/GenerateSeriesFunction.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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 org.apache.flink.table.runtime.functions.table;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.table.functions.SpecializedFunction.SpecializedContext;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.utils.LogicalTypeMerging;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * GenerateSeries implements the table function `generate_series(start, stop)`
+ * `generate_series(start, * stop, step)` which generate a series of values, from start to stop with
+ * a step size.
+ */
+@Internal
+public class GenerateSeriesFunction extends BuiltInTableFunction<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final transient DataType outputDataType;
+ private final LogicalType outputLogicalType;
+
+ public GenerateSeriesFunction(SpecializedContext specializedContext) {
+ super(BuiltInFunctionDefinitions.GENERATE_SERIES, specializedContext);
+
+ // The output type in the context is already wrapped, however, the result of the
+ // function is not. Therefore, we need a custom output type.
+ final List<LogicalType> actualTypes =
+ specializedContext.getCallContext().getArgumentDataTypes().stream()
+ .map(DataType::getLogicalType)
+ .collect(Collectors.toList());
+ this.outputLogicalType = LogicalTypeMerging.findCommonType(actualTypes).get();
+ this.outputDataType = DataTypes.of(outputLogicalType).toInternal();
+ }
+
+ @Override
+ public DataType getOutputDataType() {
+ return outputDataType;
+ }
+
+ public void eval(Number start, Number stop) {
+ eval(start, stop, 1);
+ }
+
+ public void eval(Number start, Number stop, Number step) {
+ if (isZero(step.doubleValue(), 0.000001)) {
+ throw new IllegalArgumentException("step size cannot equal zero");
+ }
+
+ double s = start.doubleValue();
Review Comment:
Could we expect here `BigDecimal`/`DECIMAL` and if yes how will it work?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #20546: [FLINK-28919][table] Add built-in generate_series function.
Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #20546:
URL: https://github.com/apache/flink/pull/20546#issuecomment-1211671010
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "f2e0b4338ac6d36e107d02a29010d45efe2f1755",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "f2e0b4338ac6d36e107d02a29010d45efe2f1755",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* f2e0b4338ac6d36e107d02a29010d45efe2f1755 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] snuyanzin commented on pull request #20546: [FLINK-28919][table] Add built-in generate_series function.
Posted by GitBox <gi...@apache.org>.
snuyanzin commented on PR #20546:
URL: https://github.com/apache/flink/pull/20546#issuecomment-1219095561
Thanks for contribution
It would be great to have filled PR template
i also left some comments
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org