[
https://issues.apache.org/jira/browse/TRAFODION-3235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16692052#comment-16692052
]
ASF GitHub Bot commented on TRAFODION-3235:
-------------------------------------------
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1747#discussion_r234717573
--- Diff: core/conn/odb/src/odb.c ---
@@ -14685,6 +14743,56 @@ static void addGlobalPointer(void *ptr)
globalPointers[nGlobalPointers++] = ptr;
}
+/* is_valid_numeric:
+* check if the string is valid numeric
+*
+* Input: str: string to be validate.
+* Input: n: length of str
+*
+* return: if str is valid numeric return 1 else return 0
+*/
+static int is_valid_numeric(const char* str, size_t n) {
+ int s = 1;
+ for (size_t i = 0; i < n; ++i) {
+ switch (s) {
+ case 1:
+ if (str[i] == '+' || str[i] == '-') s = 2;
+ else if (isdigit(str[i])) s = 3;
+ else return 0;
+ break;
+ case 2:
+ if (!isdigit(str[i])) return 0;
+ s = 3;
+ break;
+ case 3:
+ if (str[i] == '.') s = 4;
+ else if (str[i] == 'e') s = 6;
+ else if (!isdigit(str[i])) return 0;
+ break;
+ case 4:
+ if (!isdigit(str[i])) return 0;
+ s = 5;
+ break;
+ case 5:
+ if (str[i] == 'e') s = 6;
+ else if (!isdigit(str[i])) return 0;
+ break;
+ case 6:
+ if (str[i] == '+' || str[i] == '-') s = 7;
+ else if (isdigit(str[i])) s = 7;
+ else return 0;
+ break;
+ case 7:
+ if (!isdigit(str[i])) return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+ if (s == 3 || s == 7 || s == 5) return 1;
--- End diff --
I am wondering if s == 4 should be allowed here too. Consider the string
"1234."
> add div and trim function for map feature, improve bad file print function.
> ----------------------------------------------------------------------------
>
> Key: TRAFODION-3235
> URL: https://issues.apache.org/jira/browse/TRAFODION-3235
> Project: Apache Trafodion
> Issue Type: New Feature
> Components: db-utility-odb
> Reporter: 苏锦佩
> Assignee: 苏锦佩
> Priority: Major
>
> In some customer scenarios, they want below feature:
> # Div function in the map file, so the numeric data in the data file can be
> divided with some value before loading to the database. for example, we have
> a COL NUMERIC(6,2) column and the data '123456' in the data file, we can use
> the mapping rule 'COL:<field>\DIV:100' to translate the data to '1234.56'
> before loading to the database.
> # Trim function in the map file, so if some field containing leading and
> trailing space in the data file can be trimmed before loading to the
> database. for example, suppose we have a COL CHAR(20) and the data ' abc
> ' in the data file, we can use the mapping rule 'COL:<field>:TRIM' to
> translate the data to 'abc' before loading to the database.
> # Now, the odb tool will print a record for each ODBC error message in the
> bad file. But some bad row may report more than one error message, so the bad
> file may contain duplicated records. So add a fix to ensure that one bad
> record only printed once in bad file.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)