-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
sql: Fix incorrect handling of types #41607
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
@@ -345,19 +345,28 @@ func inferTypeFromMetrics(ms mapstr.M) mapstr.M { | |||
|
|||
for k, v := range ms { | |||
switch v.(type) { | |||
case float64: | |||
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64: |
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 is where based on types, key-vals are assigned under numeric
, string
or bool
Sample output: Before this patch: "sql": {
"query": "select '0054321'::varchar(20) as strCol, 12345 as intCol",
"metrics": {
"numeric": {
"strcol": 54321,
"intcol": 12345
}
},
"driver": "postgres"
} After this patch: "sql": {
"driver": "postgres",
"query": "select '0054321'::varchar(20) as strCol, 12345 as intCol",
"metrics": {
"string": {
"strcol": "0054321"
},
"numeric": {
"intcol": 12345
}
}
} So this is behaviour change in how data is now stored in ES but it's the correct change that's fixing a bug. We have to account this as well. But the thing is VARCHAR fields is now coming correctly under "sql.metrics.string" object as it should. |
@AndersonQ / @faec Could you please review this PR? This is an important bugfix that requires immediate attention. Thank you for your help. We are planning to get this merged ASAP to make it available for next release. |
@@ -167,24 +167,25 @@ func ReplaceUnderscores(ms mapstr.M) mapstr.M { | |||
} | |||
|
|||
func getValue(pval *interface{}) interface{} { |
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.
One suggestion(not related to your changes though):
We seldom need a pointer to an interface, unless there's a specific use case for it. It's like using a pointer to a pointer to an underlying concrete type. Also, we could use the any
alias, which denotes the blank interface type interface{}. Just a suggestion, see if we can try to improve this a bit.
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.
Yes, I agree with your point. There are many code smells that need to be addressed. I'll create a task and add it to our backlog.
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
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 have only skimmed this, approving to unblock.
Probably you could adjust the CODEOWNER so the data plane team isn't ping for this change next time.
(cherry picked from commit b219763)
* sql: Fix incorrect handling of types (#41607) (cherry picked from commit b219763) * Update CHANGELOG.next.asciidoc * Update CHANGELOG.next.asciidoc --------- Co-authored-by: subham sarkar <[email protected]>
(cherry picked from commit b219763)
* sql: Fix incorrect handling of types (#41607) (cherry picked from commit b219763) * Update CHANGELOG.next.asciidoc --------- Co-authored-by: subham sarkar <[email protected]>
Proposed commit message
This fixes the incorrect handling of types in SQL module. More details on the issue are present here: #40090
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
As usual.
Related issues