You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Flink Jira Bot (Jira)" <ji...@apache.org> on 2022/04/09 10:39:00 UTC

[jira] [Updated] (FLINK-17117) There are an useless cast operation for sql on blink when generate code

     [ https://issues.apache.org/jira/browse/FLINK-17117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Flink Jira Bot updated FLINK-17117:
-----------------------------------
    Labels: auto-unassigned pull-request-available stale-minor  (was: auto-unassigned pull-request-available)

I am the [Flink Jira Bot|https://github.com/apache/flink-jira-bot/] and I help the community manage its development. I see this issues has been marked as Minor but is unassigned and neither itself nor its Sub-Tasks have been updated for 180 days. I have gone ahead and marked it "stale-minor". If this ticket is still Minor, please either assign yourself or give an update. Afterwards, please remove the label or in 7 days the issue will be deprioritized.


> There are an useless  cast operation for sql on blink when generate code
> ------------------------------------------------------------------------
>
>                 Key: FLINK-17117
>                 URL: https://issues.apache.org/jira/browse/FLINK-17117
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / Runtime
>            Reporter: hehuiyuan
>            Priority: Minor
>              Labels: auto-unassigned, pull-request-available, stale-minor
>         Attachments: image-2020-04-13-19-44-19-174.png
>
>
> !image-2020-04-13-19-44-19-174.png|width=641,height=305!
>  
> This mehthod `generateOneInputStreamOperator` when OperatorCodeGenerator  generates SourceConversion:
> {code:java}
> @Override
> public void processElement($STREAM_RECORD $ELEMENT) throws Exception {
>   $inputTypeTerm $inputTerm = ($inputTypeTerm) ${converter(s"$ELEMENT.getValue()")};
>   ${ctx.reusePerRecordCode()}
>   ${ctx.reuseLocalVariableCode()}
>   ${if (lazyInputUnboxingCode) "" else ctx.reuseInputUnboxingCode()}
>   $processCode
> }
> {code}
>  
> {code:java}
>  $inputTypeTerm $inputTerm = ($inputTypeTerm) ${converter(s"$ELEMENT.getValue()")};
> {code}
> ScanUtil calls generateOneInputStreamOperator
> {code:java}
> val generatedOperator = OperatorCodeGenerator.generateOneInputStreamOperator[Any, BaseRow](
>   ctx,
>   convertName,
>   processCode,
>   outputRowType,
>   converter = inputTermConverter)
> //inputTermConverter
> val (inputTermConverter, inputRowType) = {
>   val convertFunc = CodeGenUtils.genToInternal(ctx, inputType)
>   internalInType match {
>     case rt: RowType => (convertFunc, rt)
>     case _ => ((record: String) => s"$GENERIC_ROW.of(${convertFunc(record)})",
>         RowType.of(internalInType))
>   }
> }
> {code}
> CodeGenUtils.scala  :  genToInternal
> {code:java}
> def genToInternal(ctx: CodeGeneratorContext, t: DataType): String => String = {
>   val iTerm = boxedTypeTermForType(fromDataTypeToLogicalType(t))
>   if (isConverterIdentity(t)) {
>     term => s"($iTerm) $term"
>   } else {
>     val eTerm = boxedTypeTermForExternalType(t)
>     val converter = ctx.addReusableObject(
>       DataFormatConverters.getConverterForDataType(t),
>       "converter")
>     term => s"($iTerm) $converter.toInternal(($eTerm) $term)"
>   }
> }
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)