You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by twalthr <gi...@git.apache.org> on 2018/04/23 11:46:43 UTC
[GitHub] flink pull request #5898: [FLINK-9229] [table] Fix literal handling in code ...
GitHub user twalthr opened a pull request:
https://github.com/apache/flink/pull/5898
[FLINK-9229] [table] Fix literal handling in code generation
## What is the purpose of the change
This PR fixes wrong usages of `generateNonNullLiteral`. It has been used at locations where expression are not constant.
## Brief change log
Remove invalid calls to literal methods.
## Verifying this change
This change is already covered by existing tests.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? JavaDocs
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/twalthr/flink FLINK-9229
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/5898.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #5898
----
commit 1d1217cf8e050baa09c8f93f39efb1b6b4bd68d4
Author: Timo Walther <tw...@...>
Date: 2018-04-23T11:28:21Z
[FLINK-9229] [table] Fix literal handling in code generation
----
---
[GitHub] flink pull request #5898: [FLINK-9229] [table] Fix literal handling in code ...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/flink/pull/5898
---
[GitHub] flink pull request #5898: [FLINK-9229] [table] Fix literal handling in code ...
Posted by fhueske <gi...@git.apache.org>.
Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/5898#discussion_r183716031
--- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala ---
@@ -1274,30 +1276,46 @@ abstract class CodeGenerator(
literalType: TypeInformation[_],
literalCode: String)
: GeneratedExpression = {
+
+ // mark this expression as a constant literal
+ generateTerm(literalType, literalCode).copy(literal = true)
+ }
+
+ private[flink] def generateSymbol(enum: Enum[_]): GeneratedExpression = {
+ GeneratedExpression(
+ qualifyEnum(enum),
+ "false",
+ "",
+ new GenericTypeInfo(enum.getDeclaringClass))
+ }
+
+ /**
+ * Generates access to a term (e.g. a field) that does not require unboxing logic.
+ *
+ * @param fieldType type of field
+ * @param fieldTerm expression term of field (already unboxed)
+ * @return internal unboxed field representation
+ */
+ private[flink] def generateTerm(
+ fieldType: TypeInformation[_],
+ fieldTerm: String)
+ : GeneratedExpression = {
val resultTerm = newName("result")
val nullTerm = newName("isNull")
--- End diff --
If the `nullTerm` is constant, couldn't we say `nullTerm = "false";` and simplify the remaining code?
---
[GitHub] flink pull request #5898: [FLINK-9229] [table] Fix literal handling in code ...
Posted by fhueske <gi...@git.apache.org>.
Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/5898#discussion_r183716512
--- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala ---
@@ -1274,30 +1276,46 @@ abstract class CodeGenerator(
literalType: TypeInformation[_],
literalCode: String)
: GeneratedExpression = {
+
+ // mark this expression as a constant literal
+ generateTerm(literalType, literalCode).copy(literal = true)
+ }
+
+ private[flink] def generateSymbol(enum: Enum[_]): GeneratedExpression = {
+ GeneratedExpression(
+ qualifyEnum(enum),
+ "false",
+ "",
+ new GenericTypeInfo(enum.getDeclaringClass))
+ }
+
+ /**
+ * Generates access to a term (e.g. a field) that does not require unboxing logic.
+ *
+ * @param fieldType type of field
+ * @param fieldTerm expression term of field (already unboxed)
+ * @return internal unboxed field representation
+ */
+ private[flink] def generateTerm(
+ fieldType: TypeInformation[_],
+ fieldTerm: String)
+ : GeneratedExpression = {
val resultTerm = newName("result")
val nullTerm = newName("isNull")
--- End diff --
Same is true for `generateNullLiteral()`
---
[GitHub] flink pull request #5898: [FLINK-9229] [table] Fix literal handling in code ...
Posted by twalthr <gi...@git.apache.org>.
Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/5898#discussion_r184079362
--- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala ---
@@ -1274,30 +1276,46 @@ abstract class CodeGenerator(
literalType: TypeInformation[_],
literalCode: String)
: GeneratedExpression = {
+
+ // mark this expression as a constant literal
+ generateTerm(literalType, literalCode).copy(literal = true)
+ }
+
+ private[flink] def generateSymbol(enum: Enum[_]): GeneratedExpression = {
+ GeneratedExpression(
+ qualifyEnum(enum),
+ "false",
+ "",
+ new GenericTypeInfo(enum.getDeclaringClass))
+ }
+
+ /**
+ * Generates access to a term (e.g. a field) that does not require unboxing logic.
+ *
+ * @param fieldType type of field
+ * @param fieldTerm expression term of field (already unboxed)
+ * @return internal unboxed field representation
+ */
+ private[flink] def generateTerm(
+ fieldType: TypeInformation[_],
+ fieldTerm: String)
+ : GeneratedExpression = {
val resultTerm = newName("result")
val nullTerm = newName("isNull")
--- End diff --
True, I will simplify the logic there.
---