Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but there are some issues when column keys are used.
executor.translateCall()
needs to containSetColumnAttrs
like this:
if c.Name == "Set" || c.Name == "Clear" || c.Name == "Row" || c.Name == "SetColumnAttrs" {
This is a separate bug, but it causes problems with testing this PR. It's related to #1679. In fact, we should probably audit that method to ensure that all possible query types are handling the translate calls correctly there.
- with keys, the output ends up looking like this:
"columnAttrs": [
{
"id": 0,
"key": "one",
"attrs": {
"name": "To Kill a Mockingbird",
"year": 1960
}
},
{
"id": 0,
"key": "two",
"attrs": {
"name": "No Name in the Street",
"year": 1972
}
}
}
]
It would be nice if we could suppress that "id": 0,
from the output when a key is present. It seems like we've done that elsewhere.
- We should add a test that covers the columnAttr key translation.
executor.go
Outdated
|
||
// Translate column attributes, if necessary. | ||
if e.Holder.translateFile != nil { | ||
for _, col := range resp.ColumnAttrSets { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resp.ColumnAttrSets
needs to be columnAttrSets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that break compatibility with Pilosa 1.0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that this range
loop is using the wrong argument.
resp.ColumnAttrSets
is empty, but columnAttrSets
was populated in the code block above.
The range
needs to loop over columnAttrSets
.
executor.go
Outdated
} | ||
|
||
// Translate column attributes, if necessary. | ||
if e.Holder.translateFile != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line should be
if idx.Keys() {
Updated |
executor.go
Outdated
func (e *executor) translateCall(index string, idx *Index, c *pql.Call) error { | ||
var colKey, rowKey, fieldName string | ||
if c.Name == "Set" || c.Name == "Clear" || c.Name == "Row" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely like the idea of cleaning this up, but let's make it a switch statement instead of a map lookup:
switch c.Name {
case: "Set", "Clear", "Row", "SetColumnAttrs":
...
case: "SetRowAttrs":
...
default:
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -117,7 +117,7 @@ var nameRegexp = regexp.MustCompile(`^[a-z][a-z0-9_-]{0,63}$`) | |||
// ColumnAttrSet represents a set of attributes for a vertical column in an index. | |||
// Can have a set of attributes attached to it. | |||
type ColumnAttrSet struct { | |||
ID uint64 `json:"id"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this works for the case where ID
is actually supposed to be 0
(with no column key). Should we open a ticket to write a custom JSON marshaler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we try to remove ID
from the result in the first place ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we omit the key when it doesn't apply, so it seems to make sense to omit the ID when it doesn't apply. And when there is a key, the ID is always 0
, so it's not really useful anyway. I don't have a strong opinion on this, however. I'll make a ticket suggesting we revisit that output and it can be discussed there.
Overview
[Describe what this pull request addresses.]
Fixes #1632
Pull request checklist
Code review checklist
This is the checklist that the reviewer will follow while reviewing your pull request. You do not need to do anything with this checklist, but be aware of what the reviewer will be looking for.