Comments (3)
Upstream jmoiron/sqlx works fine for structs with database/sql driver.
from ydb-go-sdk.
Query:
SELECT
status,
CAST(MAX(DateTime::ToSeconds(description_time - $since) / $period) AS Int64) as interval_number,
COUNT(1) as group_size,
MAX_BY((status, status_mtime, short_description, description_time, state_kind, sender_node), description_time) as last_item ...
FROM %s
WHERE check_id = $check_id AND description_time >= $since AND description_time < $until
GROUP BY status, DateTime::ToSeconds(description_time - $since) / $period
ORDER BY interval_number
Parsing:
var statusStr string
var intervalNumber int64
var count uint64
var lastState struct {
StatusStr string
StatusTime time.Time
Description string
DescriptionTime time.Time
StateKindStr string
SenderNode string
}
err := res.ScanWithDefaults(
&statusStr,
&intervalNumber,
&count,
db.NewTupleField(&lastState),
)
Without db.NewTupleField
, need to imlement UnmarshalYDB
for lastState
like this:
func (s *lastState) UnmarshalYDB(res types.RawValue) error {
size := res.TupleIn()
defer res.TupleOut()
if size != 6 {
return errors.New(...)
}
res.TupleItem(0)
s.StatusStr = res.String()
res.TupleItem(1)
s.StatusTime = res.Timestamp()
res.TupleItem(2)
s.Description = res.String()
res.TupleItem(3)
s.DescriptionTime = res.Timestamp()
res.TupleItem(4)
s.StateKindStr = res.String()
res.TupleItem(5)
s.SenderNode = res.String()
return nil
}
from ydb-go-sdk.
Duplicate of #1076
from ydb-go-sdk.
Related Issues (20)
- opentelemetry over `internal/query.Client`
- metrics over `internal/query.Client`
- feat: replace run SLO-tests in cloud k8s to kind-action
- Add `TzDate`, `TzTimestamp`, `TzDateTime` support for `Tuple` + rewrite tests using reflection
- feat: remove idle grpc connections from grpc balancer
- feat:
- bug: rollback breaking changes from v3.58.1
- bug: WithReaderStartTimeout has no effect
- CI: detect breaking changes: add a jobs to check build of ydb-go-sdk adapters instead of PR code version
- dev: split nested retryer calls warnings for different shared entities
- feat: ratelimiter for second+ attempts of retryer call
- feat: rename tables session method
- table option for redirect `table.Session.Execute` queries to `query.Execute`
- table option for redirect `table.Session.StreamExecuteScanQuery` queries to `query.Execute`
- table option for redirect `table.Session.ExecuteSchemeQuery` queries to `query.Execute`
- driver initialize option for redirect all table queries to `query.Execute`
- database/sql driver over query-service (enabled by opt-in)
- feat: Support duplicated column names in result
- bug: data race in `grpcClientStream`
- feat: add mutator to modify discovered endpoints
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ydb-go-sdk.