1

On Google Data Studio, I cannot create a chart from Postgres data if table columns are in camelCase. I have data in PostgreSQL where I want to get charts from. Integrating it as a data source works fine. Now, I have a problem when creating a chart.

After creating a chart and selecting a data source, I try to add a column, which results in this error:

Error with SQL statement: ERROR: column "columnname" does not exist Hint: Perhaps you meant to reference the column "table.columnName". Position: 8

It just so happens that all my columns are in camelCase. Is there no way around this? Surely this is a basic question that has been resolved.

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
wtwtwt
  • 182
  • 2
  • 7
  • Another good example why using camelCase is [discouraged](https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_upper_case_table_or_column_names) – a_horse_with_no_name Apr 27 '20 at 14:45
  • Does this answer your question? [Are PostgreSQL column names case-sensitive?](https://stackoverflow.com/questions/20878932/are-postgresql-column-names-case-sensitive) – Scoots Apr 27 '20 at 15:14
  • @Scoots Unfortunately, no. I am in a position where I cannot change the column names of the data. In Google Data Studio I'm unable to "query" the data directly i.e. `SELECT table."columnName" FROM table;`, instead what GDS seems to be doing is `SELECT table.columnname FROM table;` – wtwtwt Apr 27 '20 at 15:30
  • @wtwtwt Ahh I see. I've looked around but I've only been able to find people reporting the same issue, no one offering a solution that does not involve refactoring the table to not have uppercase characters. – Scoots Apr 27 '20 at 16:08
  • @Scoots do you think it is possible to create an alias for all columns using camelCase? I was reading into creating `VIEWS` on PostgreSQL – wtwtwt Apr 28 '20 at 12:54

1 Answers1

3

When connecting to your data source, try using 'Custom query' instead of selecting a table from your database. Then manually write your SQL query where you cast your camel case column names to lower case using sql alias. Worked for me.

example:

SELECT
  "camelCaseColA" as cola,
  "camelCaseColB" as colb,
  "camelCaseColC" as colc
FROM
  tableName as table
Brits
  • 9,438
  • 2
  • 12
  • 25
Svaeng
  • 41
  • 5