[ 
https://issues.apache.org/jira/browse/FLINK-17117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17325371#comment-17325371
 ] 

Flink Jira Bot commented on FLINK-17117:
----------------------------------------

This issue is assigned but has not received an update in 7 days so it has been 
labeled "stale-assigned". If you are still working on the issue, please give an 
update and remove the label. If you are no longer working on the issue, please 
unassign so someone else may work on it. In 7 days the issue will be 
automatically unassigned.

> 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 / Planner
>            Reporter: hehuiyuan
>            Assignee: hehuiyuan
>            Priority: Minor
>              Labels: pull-request-available, stale-assigned
>         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.3.4#803005)

Reply via email to