I have a Task to split the columns out of a SQL Statement. This worked well for me with a simple Java split on ",". But now i have an issue with additional commas inside the column. I guess the answer to this problem is pretty simple, but it will not get into my mind.
Example:
Source:
"Col_A BIGINT , COL_B TIMESTAMP , COL_C DECIMAL(10,30) , COL_D VARCHAR(20)"
My wanted Output:
Array[0] = Col_A BIGINT
Array[1] = COL_B TIMESTAMP
Array[2] = COL_C DECIMAL(10,30)
Array[3] = COL_D VARCHAR(20)
The real (and abvious) output:
Array[0] = Col_A BIGINT
Array[1] = COL_B TIMESTAMP
Array[2] = COL_C DECIMAL(10
Array[3] = 30)
Array[4] = COL_D VARCHAR(20)
The Obvious Problem is the comma between the two decimals (COL_C).
Now i am asking you if there is a nice solution on this Problem. I really want to use a single split to receive the different columns. But how can i avoid the wrong split at the decimal description.
I hope you guys can understand my problem. English is not my native language.
,,split(" , "). Else, usesplit("\\s*,\\s*(?![^)]*\\))")(it is more a work around that will fail with some input later, best is to use matching approach).