argasi / google-bigquery

Automatically exported from code.google.com/p/google-bigquery
0 stars 0 forks source link

GROUP_CONCAT() adds double quotes when a word includes double quotes #210

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a table with values like:
   Word | Num 
   fo”o | 1 
   ba”r | 1 
   ba”z | 2 

2. Run the query: bq query 'SELECT GROUP_CONCAT(word) AS words, num FROM 
[ds.table] GROUP BY num;' 

What is the expected output? What do you see instead?
The output is:
  +-----------------+-----+ 
  | words           | num | 
  +-----------------+-----+ 
  | "fo""o","ba""r" | 1 | 
  | "ba""z"         | 2 | 
  +-----------------+-----+ 

The expected output should be:
  +-----------------+-----+ 
  | words     | num | 
  +-----------------+-----+ 
  | fo"o,ba"r | 1 | 
  | ba"z      | 2 | 
  +-----------------+-----+ 

What version of the product are you using? On what operating system?
BigQuery CLI 2.0.22

Please provide any additional information below.

Original issue reported on code.google.com by mari...@google.com on 13 Jan 2015 at 10:41

GoogleCodeExporter commented 9 years ago
This is an issue reported on StackOverflow at 
http://stackoverflow.com/questions/27590126/group-concat-automatically-add-doubl
e-quotes-only-when-the-field-contains-double

Original comment by mari...@google.com on 13 Jan 2015 at 10:46

GoogleCodeExporter commented 9 years ago
I got similar problem.

originally the table is like this

attempts|id
-----------
"-7"    |1
"-7"    |1
"-7"    |1
"7"     |1 

run 'select GROUP_CONCAT(attempts) as attempts, id, FROM [my.table] GROUP EACH 
BY id;'

the results becomes
attempts                           |id
--------------------------------------
"""-7""","""-7""","""-7""","""7""" |1

why so many extra double quotes are added into the results?
would you please solve this problem?

Original comment by elexy...@gmail.com on 18 Jan 2015 at 8:38

GoogleCodeExporter commented 9 years ago
Update: We plan to add GROUP_CONCAT_UNQUOTED in order to support the expected 
semantics without breaking those who might depend on GROUP_CONCAT's current 
behavior. It'll probably be 2-3 weeks before the change gets to production, 
since there are several components that need to be updated.

Original comment by jcon...@google.com on 20 Jan 2015 at 11:59

GoogleCodeExporter commented 9 years ago
GROUP_CONCAT_UNQUOTED is now live with the desired behavior.

Original comment by jcon...@google.com on 27 Feb 2015 at 12:40