[GitHub] trafodion pull request #1642: [TRAFODION-3136] New featrue: improve on split...

2018-07-12 Thread zlei929
GitHub user zlei929 opened a pull request:

https://github.com/apache/trafodion/pull/1642

[TRAFODION-3136] New featrue: improve on split_part builtin-function.

modified:   core/sql/common/OperTypeEnum.h
modified:   core/sql/exp/ExpPackDefs.cpp
modified:   core/sql/exp/exp_clause.cpp
modified:   core/sql/exp/exp_clause.h
modified:   core/sql/exp/exp_function.cpp
modified:   core/sql/exp/exp_function.h
modified:   core/sql/generator/GenItemFunc.cpp
modified:   core/sql/optimizer/ItemExpr.cpp
modified:   core/sql/optimizer/ItemFunc.h
modified:   core/sql/optimizer/SynthType.cpp
modified:   core/sql/parser/ParKeyWords.cpp
modified:   core/sql/parser/sqlparser.y
modified:   core/sql/regress/core/EXPECTED038.LINUX
modified:   core/sql/regress/core/TEST038
modified:   docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/zlei929/trafodion TRAFODION-3136

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/trafodion/pull/1642.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 #1642


commit 2e26003eab6ba2cd2063ccd6ea55ba984ba5a5fb
Author: zlei929 
Date:   2018-07-12T11:38:25Z

modified:   core/sql/bin/SqlciErrors.txt
modified:   core/sql/common/OperTypeEnum.h
modified:   core/sql/exp/ExpPackDefs.cpp
modified:   core/sql/exp/exp_clause.cpp
modified:   core/sql/exp/exp_clause.h
modified:   core/sql/exp/exp_function.cpp
modified:   core/sql/exp/exp_function.h
modified:   core/sql/generator/GenItemFunc.cpp
modified:   core/sql/optimizer/ItemExpr.cpp
modified:   core/sql/optimizer/ItemFunc.h
modified:   core/sql/optimizer/SynthType.cpp
modified:   core/sql/parser/ParKeyWords.cpp
modified:   core/sql/parser/sqlparser.y
modified:   core/sql/regress/core/EXPECTED038.LINUX
modified:   core/sql/regress/core/TEST038
modified:   docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc




---


[GitHub] trafodion pull request #1642: [TRAFODION-3136] New featrue: improve on split...

2018-07-16 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:

https://github.com/apache/trafodion/pull/1642#discussion_r202842026
  
--- Diff: docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc ---
@@ -2919,3 +2919,15 @@ Use of predefined UDF  is deprecated and this 
function will be removed in
 
 *Recovery:* See message.
 
+[[SQL-4997]]
+== SQL 4997
+
+```
+The  operand of builtin-func  must be great than .
+```
+*Cause:* You attempted to use the random function, which some operand of 
this has range.
--- End diff --

The mention of the "random" function looks like a cut-and-paste error. 
Suggested wordsmith: "You attempted to use an invalid value for the given 
operand of the given function."


---


[GitHub] trafodion pull request #1642: [TRAFODION-3136] New featrue: improve on split...

2018-07-16 Thread DaveBirdsall
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()getFSDatatype() != REC_CLOB))
+  {
+//4051 The second operand of a split_part function must be character.
+*CmpCommon::diags()<

[GitHub] trafodion pull request #1642: [TRAFODION-3136] New featrue: improve on split...

2018-07-16 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:

https://github.com/apache/trafodion/pull/1642#discussion_r202841083
  
--- Diff: core/sql/exp/exp_function.cpp ---
@@ -2746,6 +2754,59 @@ ex_expr::exp_return_type 
ex_function_unixtime::eval(char *op_data[],
   return ex_expr::EXPR_OK;
 }
 
+ex_expr::exp_return_type ex_function_split_part::eval(char *op_data[]
+   , CollHeap* heap
+   , ComDiagsArea** diagsArea)
+{
+  size_t sourceLen = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
+  size_t patternLen = getOperand(2)->getLength(op_data[-MAX_OPERANDS+2]);
+  Lng32 indexOfTarget = *(Lng32 *)op_data[3];
+
+  if (indexOfTarget <= 0)
+{
+   ExRaiseSqlError(heap, diagsArea, (ExeErrorCode)4497);
--- End diff --

Since this is a run-time error, it should be in the 8000-8999 range. Also, 
there is an enum file for these error numbers. See 
https://cwiki.apache.org/confluence/display/TRAFODION/How+to+Add+A+New+SQL+Error+Diagnostic.


---


[GitHub] trafodion pull request #1642: [TRAFODION-3136] New featrue: improve on split...

2018-07-16 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:

https://github.com/apache/trafodion/pull/1642#discussion_r202841611
  
--- Diff: docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc ---
@@ -2919,3 +2919,15 @@ Use of predefined UDF  is deprecated and this 
function will be removed in
 
 *Recovery:* See message.
 
+[[SQL-4997]]
--- End diff --

Looks like you meant 4497 rather than 4997. But as mentioned above, since 
this is a run-time error, the error message number should be in the range 
8000-8999.


---


[GitHub] trafodion pull request #1642: [TRAFODION-3136] New featrue: improve on split...

2018-07-16 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:

https://github.com/apache/trafodion/pull/1642#discussion_r202838056
  
--- Diff: core/sql/bin/SqlciErrors.txt ---
@@ -1450,6 +1450,7 @@ $1~String1 
 4494 Z 9 BEGINNER MINOR LOGONLY LOAD is not supported on a table 
with LOB columns. Table $0~TableName has LOB column $1~ColumnName.
 4495 Z 9 BEGINNER MINOR LOGONLY UNLOAD is not supported on a 
SELECT with LOB columns. $0~ColumnName is a LOB column.
 4496 42000 9 BEGINNER MAJOR DBADMIN $0~String0 is supported only with 
datetime fields.
+4497 Z 9 BEGINNER MAJOR DBADMIN The $0~String0 operand of 
$1~String1 must be greater than $2~String2
--- End diff --

Minor point. Please add a period at the end of your new message text. Also, 
as I mentioned below, since this is a run-time message, it should be in the 
8000-8999 range.


---


[GitHub] trafodion pull request #1642: [TRAFODION-3136] New featrue: improve on split...

2018-07-16 Thread zlei929
Github user zlei929 commented on a diff in the pull request:

https://github.com/apache/trafodion/pull/1642#discussion_r202896700
  
--- Diff: docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc ---
@@ -2919,3 +2919,15 @@ Use of predefined UDF  is deprecated and this 
function will be removed in
 
 *Recovery:* See message.
 
+[[SQL-4997]]
+== SQL 4997
+
+```
+The  operand of builtin-func  must be great than .
+```
+*Cause:* You attempted to use the random function, which some operand of 
this has range.
--- End diff --

Thanks, DaveBirdall, i will commit and pull again after fixed this issues.


---


[GitHub] trafodion pull request #1642: [TRAFODION-3136] New featrue: improve on split...

2018-07-18 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/trafodion/pull/1642


---