我有一个界面,go希望支持在不同数据库中保存和加载结果,并且我想支持不同类型。
package cfgStorage
type WritableType interface {
~int | ~string | ~float64
}
type ConfigStorage[K, V WritableType] interface {
get(key K) (V, error)
set(key K, value V) (bool, error)
}
func GetValue[K, V WritableType, C ConfigStorage[K, V]](storage C, key K) (V, error) {
res, err := storage.get(key)
return res, err
}
func SetValue[K, V WritableType, C ConfigStorage[K, V]](storage C, key K, value V) (bool, error) {
res, err := storage.set(key, value)
return res, err
}
Run Code Online (Sandbox Code Playgroud)
我为此接口实现了文件系统存储,如下所示:
type FileSystemStorage[K, …Run Code Online (Sandbox Code Playgroud) 我在 BigQuery 中有一张表:
|c1|c2|c3|
----------
|a1|'b'|c1|
----------
|a1|'a'|c2|
----------
Run Code Online (Sandbox Code Playgroud)
我想按 c1 和 array_agg c2 分组并有一个如下表:
c1| c2
--------
a1|'ab'
Run Code Online (Sandbox Code Playgroud)
连接 c2 列并保存字母顺序。有人可以帮我弄这个吗?
我有这样的输入数据。
NAME | PLACE | DATE
A | X | 2020-04-30
B | Y | 2019-04-30
Run Code Online (Sandbox Code Playgroud)
我想复制 5 次并通过增加年数来更改日期
NAME | PLACE | DATE
A | X | 2020-04-30
A | X | 2021-04-30
A | X | 2022-04-30
A | X | 2023-04-30
A | X | 2024-04-30
A | X | 2025-04-30
B | Y | 2019-04-30
B | Y | 2020-04-30
B | Y | 2021-04-30
B | Y | 2022-04-30
B | Y | 2023-04-30
B …Run Code Online (Sandbox Code Playgroud)