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.

wtwtwt
  • 368
  • 4
  • 11
  • 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) –  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
  • 14,829
  • 2
  • 18
  • 31
Svaeng
  • 66
  • 5
  • So Google Data Studio basically doesnt work properly with case sensitive postgresql databases? Its a bug then, because postgres support case sensitive columns, so there is no reason not to suport it. – Paweł O. Oct 16 '22 at 16:05