You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "ojcm (via GitHub)" <gi...@apache.org> on 2023/11/16 12:01:02 UTC
[I] [BUG] TableView with JSONSchema returns incorrect type in Get [pulsar-client-go]
ojcm opened a new issue, #1132:
URL: https://github.com/apache/pulsar-client-go/issues/1132
#### Expected behavior
Using a TableView with a JSONSchema, the `Get` method should return a instance of the Go type provided via the `TableViewOptions.SchemaValueType` field.
#### Actual behavior
The type returned from the `Get` method is `map[string]interface{}` (and I presume it could also be `[]interface{}`, `string`, `float64`, `bool` or `nil` depending on the raw JSON).
#### Steps to reproduce
The following test reproduces the issue, where `exampleSchemaDef`, `testJSON`, `lookupURL` and `newTopicName` are defined in the `pulsar` package test files.
```
func TestTableViewJSONSchema(t *testing.T) {
var (
schema = NewJSONSchema(exampleSchemaDef, nil)
key = "testKey"
value = testJSON{ID: 1, Name: "Pulsar"}
)
client, err := NewClient(ClientOptions{
URL: lookupURL,
})
assert.NoError(t, err)
defer client.Close()
topic := newTopicName()
producer, err := client.CreateProducer(ProducerOptions{
Topic: topic,
Schema: schema,
})
assert.NoError(t, err)
defer producer.Close()
_, err = producer.Send(context.Background(), &ProducerMessage{
Key: key,
Value: value,
})
assert.NoError(t, err)
tv, err := client.CreateTableView(TableViewOptions{
Topic: topic,
Schema: schema,
SchemaValueType: reflect.TypeOf(value),
})
assert.NoError(t, err)
defer tv.Close()
gotValue := tv.Get(key)
// The following checks fail because `gotValue` has type map[string]interface{}
assert.IsType(t, value, gotValue)
assert.Equal(t, value, gotValue)
}
```
#### System configuration
**Pulsar version**: 3.1.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] TableView with JSONSchema returns incorrect type in Get [pulsar-client-go]
Posted by "RobertIndie (via GitHub)" <gi...@apache.org>.
RobertIndie commented on issue #1132:
URL: https://github.com/apache/pulsar-client-go/issues/1132#issuecomment-1814412530
@ojcm Thanks. I assign this issue to you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] TableView with JSONSchema returns incorrect type in Get [pulsar-client-go]
Posted by "RobertIndie (via GitHub)" <gi...@apache.org>.
RobertIndie closed issue #1132: [BUG] TableView with JSONSchema returns incorrect type in Get
URL: https://github.com/apache/pulsar-client-go/issues/1132
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] TableView with JSONSchema returns incorrect type in Get [pulsar-client-go]
Posted by "ojcm (via GitHub)" <gi...@apache.org>.
ojcm commented on issue #1132:
URL: https://github.com/apache/pulsar-client-go/issues/1132#issuecomment-1814311573
I believe I have a fix for this. Once it has been reviewed by my colleagues I'll open a PR in this repo. I expect that will be later today or tomorrow.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org