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

ASF GitHub Bot commented on TRAFODION-3136:
-------------------------------------------

Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1642#discussion_r202839688
  
    --- Diff: core/sql/optimizer/SynthType.cpp ---
    @@ -7139,3 +7139,79 @@ const NAType * ItmLeadOlapFunction::synthesizeType()
        return result;
     }
     
    +const NAType * SplitPart::synthesizeType()
    +{
    +  ValueId vid1 = child(0)->getValueId(); 
    +  ValueId vid2 = child(1)->getValueId();
    +  ValueId vid3 = child(2)->getValueId();
    +  vid1.coerceType(NA_CHARACTER_TYPE);
    +  vid2.coerceType(NA_CHARACTER_TYPE);
    +  SQLInt si(NULL);
    +  vid3.coerceType(NA_NUMERIC_TYPE);
    +
    +  const NAType *operand1 = &child(0)->getValueId().getType();
    +  const NAType *operand2 = &child(1)->getValueId().getType();
    +  const NAType *operand3 = &child(2)->getValueId().getType();
    +
    +  if ((operand1->getTypeQualifier() != NA_CHARACTER_TYPE) 
    +      && (operand1->getFSDatatype() != REC_CLOB))
    +  {
    +    //4051 The first operand of a split_part function must be character.
    +    *CmpCommon::diags()<<DgSqlCode(-4051) << DgString0(getTextUpper());
    +    return NULL;
    +  }
    +  if ((operand2->getTypeQualifier() != NA_CHARACTER_TYPE)
    +      && (operand1->getFSDatatype() != REC_CLOB))
    +  {
    +    //4051 The second operand of a split_part function must be character.
    +    *CmpCommon::diags()<<DgSqlCode(-4051) << DgString0(getTextUpper());
    --- End diff --
    
    You'll need to add a new error message here. Error 4051 reads, "The first 
operand of function xxxx must be character." Alternatively, you could change 
error 4051 to parameterize "first". That's not too hard; I only see five or six 
references to this message elsewhere. 


> Improve on split_part builtin-function
> --------------------------------------
>
>                 Key: TRAFODION-3136
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-3136
>             Project: Apache Trafodion
>          Issue Type: Improvement
>            Reporter: zhang.lei
>            Assignee: zhang.lei
>            Priority: Major
>
> {color:#FF0000}use like below descripyon:{color}
>  
> >>select split_part('sa:sbl:sc', ':', 1) from t038sf;
> (EXPR)
> ---------
> sa
> --- 1 row(s) selected.
> >>select split_part('sa:sbl:sc', ':', 2) from t038sf;
> (EXPR)
> ---------
> sbl
> --- 1 row(s) selected.
> >>select split_part('sa:sbl:sc', ':', 3) from t038sf;
> (EXPR) 
> ---------
> sc 
> --- 1 row(s) selected.
> >>
> >>-- **ERROR** 
> >>select split_part('sa:sbl:sc', ':', 0) from t038sf;
> *** ERROR[4497] The Third operand of split_part must be greater than 0
> --- 0 row(s) selected.
> >>–**EMPTY RESULT**
> >>select split_part('sa:sbl:sc', ':', 4) from t038sf;
> (EXPR) 
> ---------
>  
> --- 1 row(s) selected.
>  
> >> create table T038sf(a int, b char(10), c varchar(30));
> >>insert into T038sf values(110, 'a/b/c', 'sa/dsd/s');
> --- 1 row(s) inserted.
> >>insert into T038sf values(111, 'sasd', 'dsa:/~sd');
> --- 1 row(s) inserted.
> >>insert into T038sf values(112, '#$%$#@', 'dsasggggsad');
> --- 1 row(s) inserted.
> >>insert into T038sf values(114, 'a', '这是^中文:测试');
> --- 1 row(s) inserted.
> >>select split_part(c, '/', 2) from t038sf;
> (EXPR) 
> ------------------------------
> dsd 
> ~sd 
>  
>  
> --- 4 row(s) selected.
> >>select split_part(c, 'ggg', 2) from t038sf;
> (EXPR) 
> ------------------------------
>  
> gsad
> --- 4 row(s) selected.
> >>select split_part(c, 'sd', 1) from t038sf;
> (EXPR) 
> ------------------------------
> sa/d 
> dsa:/~ 
>  
>  
> --- 4 row(s) selected.
>  
> >>select split_part(c, ':', 1) from t038sf;
> (EXPR) 
> ------------------------------
>  
> 这是^中文
> --- 4 row(s) selected.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to