Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TimeSeries] Invalid bucket groups in the column is named 'timestamp' #827

Closed
Algunenano opened this issue Dec 22, 2017 · 3 comments
Closed
Assignees

Comments

@Algunenano
Copy link
Contributor

Due to name conflicts the 'GROUP BY' clause is incorrect and you might get several bins with the same number. For example:

"aggregation":"decade",
   "offset":0,
   "timestamp_start":631152000,
   "bin_width":315576000,
   "bins_count":3,
   "bins_start":631152000,
   "nulls":0,
   "bins":[  
      {  
         "bin":0,
         "min":631152000,
         "max":631152000,
         "avg":631152000,
         "freq":123,
         "timestamp":631152000
      },
      {  
         "bin":0,
         "min":631152000,
         "max":631152000,
         "avg":631152000,
         "freq":119,
         "timestamp":631152000
      },
      {  
         "bin":0,
         "min":631152000,
         "max":631152000,
         "avg":631152000,
         "freq":122,
         "timestamp":631152000
      },
      {  
         "bin":0,
         "min":631152000,
         "max":631152000,
         "avg":631152000,
         "freq":120,
         "timestamp":631152000
      },
      {  
         "bin":1,
         "min":946684800,
         "max":946684800,
         "avg":946684800,
         "freq":116,
         "timestamp":946684800
      },
      {  
         "bin":1,
         "min":946684800,
         "max":946684800,
         "avg":946684800,
         "freq":127,
         "timestamp":946684800
      },
      {  
         "bin":1,
         "min":946684800,
         "max":946684800,
         "avg":946684800,
         "freq":120,
         "timestamp":946684800
      },
      {  
         "bin":1,
         "min":946684800,
         "max":946684800,
         "avg":946684800,
         "freq":129,
         "timestamp":946684800
      },
      {  
         "bin":1,
         "min":946684800,
         "max":946684800,
         "avg":946684800,
         "freq":126,
         "timestamp":946684800
      },
      {  
         "bin":1,
         "min":946684800,
         "max":946684800,
         "avg":946684800,
         "freq":124,
         "timestamp":946684800
      },
      {  
         "bin":1,
         "min":946684800,
         "max":946684800,
         "avg":946684800,
         "freq":125,
         "timestamp":946684800
      },
      {  
         "bin":2,
         "min":1262304000,
         "max":1262304000,
         "avg":1262304000,
         "freq":116,
         "timestamp":1262304000
      },
      {  
         "bin":2,
         "min":1262304000,
         "max":1262304000,
         "avg":1262304000,
         "freq":110,
         "timestamp":1262304000
      },
      {  
         "bin":2,
         "min":1262304000,
         "max":1262304000,
         "avg":1262304000,
         "freq":112,
         "timestamp":1262304000
      },
      {  
         "bin":2,
         "min":1262304000,
         "max":1262304000,
         "avg":1262304000,
         "freq":117,
         "timestamp":1262304000
      },
      {  
         "bin":2,
         "min":1262304000,
         "max":1262304000,
         "avg":1262304000,
         "freq":113,
         "timestamp":1262304000
      }
   ],
   "type":"histogram"
}

It's not directly related to https://github.com/CartoDB/support/issues/1071 but appeared while testing it.

@Algunenano
Copy link
Contributor Author

Some information about why this was happening:

From PostgreSQL documentation:
In case of ambiguity, a GROUP BY name will be interpreted as an input-column name rather than an output column name.

So as the internal query (input) had a column called 'timestamp' the GROUP BY was choosing that instead of the one declared in the 'SELECT'.
Changing the name in the SELECT was an option but the possibility of clashing would always be there, but I GROUP BY N with N being the ordinal of the select column is safe.

@ramiroaznar
Copy link

Hey @Algunenano maybe you can have a look at this one too https://github.com/CartoDB/support/issues/1181

@Algunenano
Copy link
Contributor Author

Added a commit to also fix https://github.com/CartoDB/support/issues/1181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants