├── .goreleaser.yaml ├── arrow ├── math │ ├── int64.tmpldata │ ├── float64.tmpldata │ ├── uint64.tmpldata │ ├── _lib │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── float64.c │ │ ├── arch.h │ │ ├── int64.c │ │ └── uint64.c │ ├── type_noasm.go.tmpl │ ├── type_s390x.go.tmpl │ ├── int64_arm64.go │ ├── int64_noasm.go │ ├── int64_s390x.go │ ├── uint64_noasm.go │ ├── float64_noasm.go │ ├── math_noasm.go │ ├── uint64_arm64.go │ ├── uint64_s390x.go │ ├── float64_arm64.go │ ├── float64_s390x.go │ ├── math_arm64.go │ ├── math_s390x.go │ ├── type_amd64.go.tmpl │ ├── int64_amd64.go │ ├── uint64_amd64.go │ ├── float64_amd64.go │ ├── int64_avx2_amd64.go │ ├── int64_sse4_amd64.go │ ├── type_simd_amd64.go.tmpl │ ├── uint64_avx2_amd64.go │ ├── uint64_sse4_amd64.go │ ├── float64_avx2_amd64.go │ ├── float64_sse4_amd64.go │ ├── math_amd64.go │ ├── int64.go │ ├── uint64.go │ ├── float64.go │ └── type.go.tmpl ├── internal │ ├── cpu │ │ ├── cpu_arm64.go │ │ ├── cpu_s390x.go │ │ ├── cpu_x86.s │ │ └── cpu_test.go │ ├── debug │ │ ├── log_off.go │ │ ├── assert_off.go │ │ ├── log_on.go │ │ ├── assert_on.go │ │ ├── util.go │ │ └── doc.go │ ├── testing │ │ └── tools │ │ │ ├── bool.go │ │ │ ├── bits_test.go │ │ │ └── bits.go │ ├── flatbuf │ │ ├── UnionMode.go │ │ ├── DateUnit.go │ │ ├── Precision.go │ │ ├── CompressionType.go │ │ ├── Bool.go │ │ ├── Endianness.go │ │ ├── List.go │ │ └── Utf8.go │ └── flight_integration │ │ └── cmd │ │ └── arrow-flight-integration-server │ │ └── main.go ├── numeric.schema.json ├── memory │ ├── _lib │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── memory.c │ │ └── arch.h │ ├── doc.go │ ├── memory_js_wasm.go │ ├── memory_noasm.go │ ├── cgo_allocator_logging.go │ ├── cgo_allocator_defaults.go │ ├── memory_sse4_amd64.go │ ├── memory_amd64.go │ ├── memory.go │ ├── allocator.go │ ├── util.go │ ├── memory_avx2_amd64.go │ ├── internal │ │ └── cgoalloc │ │ │ └── allocator.h │ └── go_allocator.go ├── scalar │ ├── numeric.gen.go.tmpldata │ └── compare.go ├── array │ ├── doc.go │ ├── util.go │ └── bufferbuilder_byte.go ├── Gopkg.toml ├── flight │ └── gen.go ├── endian │ ├── big.go │ └── little.go ├── csv │ └── testdata │ │ ├── simple.csv │ │ ├── header.csv │ │ └── types.csv ├── bitutil │ ├── endian_s390x.go │ └── endian_default.go ├── type_traits_boolean.go ├── datatype_numeric.gen.go.tmpldata ├── datatype_null.go ├── _examples │ └── helloworld │ │ └── main.go ├── Gopkg.lock ├── datatype_null_test.go ├── ipc │ └── record_batch_writer.go ├── datatype_numeric.gen.go.tmpl └── float16 │ └── float16_test.go ├── tea ├── go.mod └── utils │ └── utils_test.go ├── .gitignore ├── examples ├── go.mod ├── conf.ini ├── sql │ ├── create_table_with_hints │ │ └── main.go │ ├── select_data_with_hints │ │ └── main.go │ ├── insert_data │ │ └── main.go │ └── create_table │ │ └── main.go └── sdk │ ├── table │ ├── table_deletion │ │ └── main.go │ ├── table_exists │ │ └── main.go │ ├── view_exists │ │ └── main.go │ ├── table_type │ │ └── main.go │ ├── table_owner │ │ └── main.go │ ├── table_size │ │ └── main.go │ ├── list_tables │ │ └── main.go │ ├── get_table_data_masking_policy │ │ └── main.go │ ├── get_table │ │ └── main.go │ ├── table_time │ │ └── main.go │ ├── auto_partition_table │ │ └── main.go │ └── table_schema │ │ └── main.go │ ├── function │ ├── get_function │ │ └── main.go │ ├── delete_function │ │ └── main.go │ ├── create_function │ │ └── main.go │ └── update_function │ │ └── main.go │ ├── aliyun_credential │ ├── use_ak │ │ ├── use_ak_from_ini │ │ │ └── main.go │ │ └── use_ak_from_env │ │ │ └── main.go │ └── use_sts_token │ │ ├── use_sts_token_from_ini │ │ └── main.go │ │ ├── use_sts_from_credentials_uri │ │ └── main.go │ │ ├── use_sts_token_from_env │ │ └── main.go │ │ ├── use_sts_token_by_custom_provider │ │ └── main.go │ │ └── use_sts_token_from_ecs_ram_role │ │ └── main.go │ ├── partition │ ├── add_partitions │ │ └── main.go │ ├── drop_partitions │ │ └── main.go │ ├── list_partition_values │ │ └── main.go │ ├── get_partition │ │ └── main.go │ ├── list_partitions │ │ └── main.go │ └── get_partition_ext │ │ └── main.go │ ├── resources │ ├── delete_resources │ │ └── main.go │ ├── list_resources │ │ └── main.go │ ├── update_resource │ │ └── main.go │ └── create_resource │ │ └── main.go │ ├── security_manager │ └── main.go │ ├── tunnel │ ├── init_tunnel │ │ └── main.go │ ├── upload_data_use_protoc_with_quota │ │ └── main.go │ └── download_data_use_protoc_with_quota │ │ └── main.go │ ├── instance │ ├── get_instance │ │ └── main.go │ └── list_instances │ │ └── main.go │ ├── create_table_with_json_column │ └── main.go │ ├── logview │ └── main.go │ ├── exec_sql │ └── main.go │ └── select_data │ └── main.go ├── odps ├── common │ ├── util.go │ ├── result.go │ └── property.go ├── admin_task.go ├── tunnel │ ├── common_test.go │ ├── const.go │ ├── protoc_common.go │ └── session_config_schema_test.go ├── options │ ├── odps_options.go │ └── doc.go ├── tables_test.go ├── doc.go ├── data │ ├── json.go │ ├── null.go │ ├── binary.go │ ├── record.go │ └── util.go ├── restclient │ └── rest_client_test.go ├── account │ └── bearer_token_account.go └── security │ └── auth_query_instance.go ├── .github └── workflows │ ├── golangci-lint.yml │ ├── release.yml │ ├── ci-go1.15.yml │ └── ci.yml ├── go.mod ├── .golangci.yml └── sqldriver └── driver.go /.goreleaser.yaml: -------------------------------------------------------------------------------- 1 | builds: 2 | - skip: true 3 | -------------------------------------------------------------------------------- /arrow/math/int64.tmpldata: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "Int64", 3 | "Type": "int64" 4 | } -------------------------------------------------------------------------------- /arrow/math/float64.tmpldata: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "Float64", 3 | "Type": "float64" 4 | } -------------------------------------------------------------------------------- /arrow/math/uint64.tmpldata: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "Uint64", 3 | "Type": "uint64" 4 | } -------------------------------------------------------------------------------- /tea/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/aliyun/aliyun-odps-go-sdk/tea 2 | 3 | go 1.15 4 | -------------------------------------------------------------------------------- /arrow/internal/cpu/cpu_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | const CacheLineSize = 64 8 | -------------------------------------------------------------------------------- /arrow/internal/cpu/cpu_s390x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | const CacheLineSize = 256 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | workspace.xml 2 | .DS_Store 3 | .tmp 4 | .settings 5 | *~ 6 | .pyc 7 | *.py[co] 8 | # IDEA IDE 9 | .idea* 10 | build/ 11 | dist/ 12 | out/ 13 | coverage.* 14 | .history/ 15 | /document/ 16 | /examples/sdk/admin_task/ 17 | /examples/config.ini 18 | -------------------------------------------------------------------------------- /examples/go.mod: -------------------------------------------------------------------------------- 1 | module odpsexample 2 | 3 | go 1.15 4 | 5 | replace github.com/aliyun/aliyun-odps-go-sdk => ../ 6 | 7 | require ( 8 | github.com/aliyun/aliyun-odps-go-sdk v0.3.8 9 | github.com/aliyun/credentials-go v1.3.10 10 | github.com/pkg/errors v0.9.1 11 | ) 12 | -------------------------------------------------------------------------------- /examples/conf.ini: -------------------------------------------------------------------------------- 1 | ; Inline comment is not allowed 2 | [odps] 3 | access_id = "" 4 | access_key = "" 5 | sts_token = "" 6 | endpoint = "" 7 | project = "" 8 | tcp_connection_timeout = "" 9 | http_timeout = "" 10 | tunnel_quota_name = "" 11 | 12 | ; set odps flags 13 | hints.odps.namespace.schema = true 14 | hints.odps.default.schema = "" 15 | -------------------------------------------------------------------------------- /tea/utils/utils_test.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestToString(t *testing.T) { 9 | value := "hello" 10 | var ptr *string 11 | ptr = &value 12 | 13 | t.Log(fmt.Sprintf("%v", ptr)) // 0x000 14 | t.Log(*ToString(ptr)) // hello 15 | t.Log(*ToString(value)) // hello 16 | } 17 | -------------------------------------------------------------------------------- /arrow/numeric.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "templates", 3 | "type": "array", 4 | "items": { 5 | "title": "template", 6 | "type": "object", 7 | "properties": { 8 | "Name": { 9 | "type": "string", 10 | "description": "The name of the template type" 11 | } 12 | }, 13 | "required": ["Name"] 14 | } 15 | } -------------------------------------------------------------------------------- /odps/common/util.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | func QuoteString(str string) string { 8 | str = strings.ReplaceAll(str, "'", "\\'") 9 | return "'" + str + "'" 10 | } 11 | 12 | func QuoteRef(ref string) string { 13 | return "`" + ref + "`" 14 | } 15 | 16 | // StringToBool 将字符串转换为布尔值,不合法时返回 false 17 | func StringToBool(s string) bool { 18 | return strings.ToLower(s) == "true" 19 | } 20 | -------------------------------------------------------------------------------- /odps/admin_task.go: -------------------------------------------------------------------------------- 1 | package odps 2 | 3 | import ( 4 | "encoding/xml" 5 | ) 6 | 7 | type AdminTask struct { 8 | XMLName xml.Name `xml:"Admin"` 9 | TaskName `xml:"Name"` 10 | // 注意: TaskConfig和Command的顺序不能更改 11 | TaskConfig 12 | Command string `xml:"Command"` 13 | } 14 | 15 | func NewAdminTask(name string, command string) *AdminTask { 16 | return &AdminTask{ 17 | TaskName: TaskName(name), 18 | Command: command, 19 | } 20 | } 21 | 22 | func (t *AdminTask) TaskType() string { 23 | return "AdminTask" 24 | } 25 | -------------------------------------------------------------------------------- /examples/sql/create_table_with_hints/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "log" 6 | ) 7 | 8 | func main() { 9 | dsn := "http://:@?project=&odps.sql.type.system.odps2=true&odps.sql.decimal.odps2=true" 10 | 11 | db, err := sql.Open("odps", dsn) 12 | if err != nil { 13 | log.Fatalf("%+v", err) 14 | } 15 | 16 | sqlStr := "create table table_with_date (date_col DATE);" 17 | _, err = db.Exec(sqlStr) 18 | if err != nil { 19 | log.Fatalf("%+v", err) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /odps/tunnel/common_test.go: -------------------------------------------------------------------------------- 1 | package tunnel_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/pkg/errors" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/tunnel" 9 | ) 10 | 11 | func TestRetry(t *testing.T) { 12 | var err error = nil 13 | 14 | err = tunnel.Retry(func() error { 15 | _, err := Mock_commit() 16 | return errors.WithStack(err) 17 | }) 18 | 19 | if err == nil { 20 | t.Error("should be error") 21 | } 22 | } 23 | 24 | func Mock_commit() (string, error) { 25 | return "", errors.New("commit fail") 26 | } 27 | -------------------------------------------------------------------------------- /.github/workflows/golangci-lint.yml: -------------------------------------------------------------------------------- 1 | name: golangci-lint 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | 8 | permissions: 9 | contents: read 10 | pull-requests: read 11 | checks: write 12 | 13 | jobs: 14 | golangci: 15 | name: lint 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v4 19 | - uses: actions/setup-go@v5 20 | with: 21 | go-version: stable 22 | - name: golangci-lint 23 | uses: golangci/golangci-lint-action@v6 24 | with: 25 | version: v1.61 26 | only-new-issues: true 27 | -------------------------------------------------------------------------------- /arrow/internal/cpu/cpu_x86.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386 amd64 amd64p32 6 | 7 | #include "textflag.h" 8 | 9 | // func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) 10 | TEXT ·cpuid(SB), NOSPLIT, $0-24 11 | MOVL eaxArg+0(FP), AX 12 | MOVL ecxArg+4(FP), CX 13 | CPUID 14 | MOVL AX, eax+8(FP) 15 | MOVL BX, ebx+12(FP) 16 | MOVL CX, ecx+16(FP) 17 | MOVL DX, edx+20(FP) 18 | RET 19 | 20 | // func xgetbv() (eax, edx uint32) 21 | TEXT ·xgetbv(SB),NOSPLIT,$0-8 22 | #ifdef GOOS_nacl 23 | // nacl does not support XGETBV. 24 | MOVL $0, eax+0(FP) 25 | MOVL $0, edx+4(FP) 26 | #else 27 | MOVL $0, CX 28 | XGETBV 29 | MOVL AX, eax+0(FP) 30 | MOVL DX, edx+4(FP) 31 | #endif 32 | RET 33 | -------------------------------------------------------------------------------- /arrow/math/_lib/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | .idea 18 | cmake-build-* -------------------------------------------------------------------------------- /arrow/memory/_lib/.gitignore: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | .idea 18 | cmake-build-* -------------------------------------------------------------------------------- /examples/sdk/table/table_deletion/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("all_types_demo") 26 | 27 | err = table.Delete() 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/aliyun/aliyun-odps-go-sdk 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/aliyun/credentials-go v1.3.10 7 | github.com/golang/protobuf v1.5.3 8 | github.com/golang/snappy v0.0.4 9 | github.com/google/flatbuffers v23.5.26+incompatible 10 | github.com/google/uuid v1.3.0 11 | github.com/klauspost/compress v1.15.9 12 | github.com/pierrec/lz4/v4 v4.1.18 13 | github.com/pkg/errors v0.9.1 14 | github.com/stretchr/testify v1.8.3 15 | golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 16 | golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 17 | gonum.org/v1/gonum v0.13.0 18 | google.golang.org/grpc v1.56.3 19 | google.golang.org/protobuf v1.33.0 20 | gopkg.in/ini.v1 v1.67.0 21 | ) 22 | 23 | replace ( 24 | golang.org/x/net => golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd 25 | golang.org/x/sys => golang.org/x/sys v0.0.0-20220412211240-33da011f77ad 26 | ) 27 | -------------------------------------------------------------------------------- /odps/options/odps_options.go: -------------------------------------------------------------------------------- 1 | package options 2 | 3 | type OdpsOptions struct { 4 | LogViewVersion LogViewVersion 5 | RegionId string 6 | } 7 | 8 | type OdpsOption func(*OdpsOptions) 9 | 10 | // NewOdpsOptions initializes a new instance of OdpsOptions. 11 | func NewOdpsOptions(opts ...OdpsOption) *OdpsOptions { 12 | o := &OdpsOptions{ 13 | LogViewVersion: Auto, 14 | RegionId: "cn", 15 | } 16 | for _, opt := range opts { 17 | opt(o) 18 | } 19 | return o 20 | } 21 | 22 | func WithRegionId(regionId string) OdpsOption { 23 | return func(o *OdpsOptions) { 24 | o.RegionId = regionId 25 | } 26 | } 27 | 28 | type LogViewVersion int 29 | 30 | const ( 31 | Auto LogViewVersion = iota 32 | LegacyLogView 33 | JobInsight 34 | ) 35 | 36 | func WithLogViewVersion(version LogViewVersion) OdpsOption { 37 | return func(o *OdpsOptions) { 38 | o.LogViewVersion = version 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/sdk/table/table_exists/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("all_types_demo") 26 | 27 | ok, err := table.Exists() 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | 32 | println(ok) 33 | } 34 | -------------------------------------------------------------------------------- /examples/sdk/table/view_exists/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("testcreatevirtualview") 26 | 27 | ok, err := table.Exists() 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | 32 | println(ok) 33 | } 34 | -------------------------------------------------------------------------------- /examples/sql/select_data_with_hints/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "fmt" 6 | "log" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/sqldriver" 9 | ) 10 | 11 | func main() { 12 | dsn := "http://:@" + 13 | "?project=&odps.namespace.schema=true&odps.default.schema=&other.odps.flag=&enableLogview=true" 14 | 15 | db, err := sql.Open("odps", dsn) 16 | if err != nil { 17 | log.Fatalf("%+v", err) 18 | } 19 | selectSql := ` select date_col 20 | from @table_name; 21 | ` 22 | 23 | rows, err := db.Query( 24 | selectSql, 25 | sql.Named("table_name", "table1"), 26 | ) 27 | if err != nil { 28 | log.Fatalf("%+v", err) 29 | } 30 | 31 | var date sqldriver.NullDate 32 | for rows.Next() { 33 | err = rows.Scan(&date) 34 | if err != nil { 35 | log.Fatalf("%+v", err) 36 | } 37 | fmt.Println(date) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /odps/tables_test.go: -------------------------------------------------------------------------------- 1 | package odps_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | ) 8 | 9 | func TestTables_List(t *testing.T) { 10 | odpsIns.DefaultProject().Schemas().Get("mv").Tables().List(func(table *odps.Table, err error) { 11 | err = table.Load() 12 | if err != nil { 13 | t.Error(err) 14 | } 15 | print(table.Name() + "\t" + table.Type().String() + "\n") 16 | }) 17 | } 18 | 19 | func TestTables_BatchLoadTables(t *testing.T) { 20 | var tables []string 21 | 22 | odpsIns.DefaultProject().Schemas().Get("mv").Tables().List(func(table *odps.Table, err error) { 23 | tables = append(tables, table.Name()) 24 | }) 25 | 26 | loadTables, err := odpsIns.Schemas().Get("mv").Tables().BatchLoadTables(tables) 27 | if err != nil { 28 | t.Error(err) 29 | } 30 | for _, table := range loadTables { 31 | print(table.Name() + "\t" + table.Type().String() + "\n") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /arrow/scalar/numeric.gen.go.tmpldata: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Name": "Int8", 4 | "Type": "int8", 5 | "Size": 8 6 | }, 7 | { 8 | "Name": "Int16", 9 | "Type": "int16", 10 | "Size": 16 11 | }, 12 | { 13 | "Name": "Int32", 14 | "Type": "int32", 15 | "Size": 32 16 | }, 17 | { 18 | "Name": "Int64", 19 | "Type": "int64", 20 | "Size": 64 21 | }, 22 | { 23 | "Name": "Uint8", 24 | "Type": "uint8", 25 | "Size": 8 26 | }, 27 | { 28 | "Name": "Uint16", 29 | "Type": "uint16", 30 | "Size": 16 31 | }, 32 | { 33 | "Name": "Uint32", 34 | "Type": "uint32", 35 | "Size": 32 36 | }, 37 | { 38 | "Name": "Uint64", 39 | "Type": "uint64", 40 | "Size": 64 41 | }, 42 | { 43 | "Name": "Float32", 44 | "Type": "float32", 45 | "Size": 32 46 | }, 47 | { 48 | "Name": "Float64", 49 | "Type": "float64", 50 | "Size": 64 51 | } 52 | ] 53 | -------------------------------------------------------------------------------- /examples/sdk/function/get_function/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | odpsIns.SetCurrentSchemaName("default") 24 | 25 | functions := odps.NewFunctions(odpsIns) 26 | function, _ := functions.Get("test_sleep2") 27 | 28 | err = function.Load() 29 | if err != nil { 30 | panic(err) 31 | } 32 | fmt.Printf("%+v\n", function) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /examples/sdk/aliyun_credential/use_ak/use_ak_from_ini/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // create ini file with content like the following 13 | /* 14 | ; Inline comment is not allowed 15 | [odps] 16 | access_id = 17 | access_key = 18 | endpoint = 19 | project = 20 | */ 21 | 22 | // Specify the ini file path 23 | configPath := "./config.ini" 24 | conf, err := odps.NewConfigFromIni(configPath) 25 | if err != nil { 26 | log.Fatalf("%+v", err) 27 | } 28 | 29 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 30 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 31 | // Set the Default Maxcompute project used By Odps instance 32 | odpsIns.SetDefaultProjectName(conf.ProjectName) 33 | 34 | fmt.Printf("odps:%#v\n", odpsIns) 35 | } 36 | -------------------------------------------------------------------------------- /examples/sdk/partition/add_partitions/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("all_types_demo") 26 | 27 | err = table.AddPartitions(true, []string{"p1=23/p2=beijing", "p1=24/p2=shanghai"}) 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/sdk/partition/drop_partitions/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("all_types_demo") 26 | 27 | err = table.DeletePartitions(true, []string{"p1=23/p2=beijing", "p1=24/p2=shanghai"}) 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/sdk/table/table_type/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("all_types_demo") 26 | 27 | err = table.Load() 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | 32 | // Get table owner 33 | t := table.Type() 34 | println("type is ", t) 35 | } 36 | -------------------------------------------------------------------------------- /examples/sdk/table/table_owner/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("all_types_demo") 26 | 27 | err = table.Load() 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | 32 | // Get table owner 33 | owner := table.Owner() 34 | println("owner is ", owner) 35 | } 36 | -------------------------------------------------------------------------------- /arrow/array/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | /* 18 | Package array provides implementations of various Arrow array types. 19 | */ 20 | package array 21 | -------------------------------------------------------------------------------- /arrow/array/util.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package array 18 | 19 | func min(a, b int) int { 20 | if a < b { 21 | return a 22 | } 23 | return b 24 | } 25 | -------------------------------------------------------------------------------- /arrow/internal/debug/log_off.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !debug 18 | // +build !debug 19 | 20 | package debug 21 | 22 | func Log(interface{}) {} 23 | -------------------------------------------------------------------------------- /examples/sdk/aliyun_credential/use_sts_token/use_sts_token_from_ini/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // create config.ini file with content like the following 13 | /* 14 | ; Inline comment is not allowed 15 | [odps] 16 | access_id = 17 | access_key = 18 | sts_token = 19 | endpoint = 20 | project = 21 | */ 22 | // Specify the ini file path 23 | configPath := "" 24 | conf, err := odps.NewConfigFromIni(configPath) 25 | if err != nil { 26 | log.Fatalf("%+v", err) 27 | } 28 | 29 | stsAccount := account.NewStsAccount(conf.AccessId, conf.AccessKey, conf.StsToken) 30 | odpsIns := odps.NewOdps(stsAccount, conf.Endpoint) 31 | // Set the Default Maxcompute project used by Odps instance 32 | odpsIns.SetDefaultProjectName(conf.ProjectName) 33 | 34 | fmt.Printf("odps:%#v\n", odpsIns) 35 | } 36 | -------------------------------------------------------------------------------- /odps/options/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Package options provides a set of configuration options to customize the behavior of the SDK. 18 | package options 19 | -------------------------------------------------------------------------------- /arrow/memory/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | /* 18 | Package memory provides support for allocating and manipulating memory at a low level. 19 | */ 20 | package memory 21 | -------------------------------------------------------------------------------- /examples/sdk/function/delete_function/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | odpsIns.SetCurrentSchemaName("default") 24 | 25 | functions := odps.NewFunctions(odpsIns) 26 | function, _ := functions.Get("test_sleep2") 27 | 28 | fmt.Println(function.Exist()) 29 | err = functions.Delete("test_sleep2") 30 | if err != nil { 31 | log.Fatalf("%+v", err) 32 | } 33 | fmt.Println(function.Exist()) 34 | } 35 | -------------------------------------------------------------------------------- /arrow/memory/memory_js_wasm.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build wasm 18 | // +build wasm 19 | 20 | package memory 21 | 22 | func init() { 23 | memset = memory_memset_go 24 | } 25 | -------------------------------------------------------------------------------- /arrow/memory/memory_noasm.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build noasm 18 | // +build noasm 19 | 20 | package memory 21 | 22 | func init() { 23 | memset = memory_memset_go 24 | } 25 | -------------------------------------------------------------------------------- /examples/sdk/partition/list_partition_values/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("test_partitioned_25000x1k") 26 | 27 | partitionValues, err := table.GetPartitionValues() 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | 32 | for _, pv := range partitionValues { 33 | println(pv) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/sdk/resources/delete_resources/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | odpsIns.SetCurrentSchemaName("default") 24 | 25 | resources := odps.NewResources(odpsIns) 26 | resource1 := resources.Get("bank_customer.txt") 27 | fmt.Println(resource1.Exist()) 28 | 29 | err = resources.Delete("bank_customer.txt") 30 | if err != nil { 31 | log.Fatal(err) 32 | } 33 | fmt.Println(resource1.Exist()) 34 | } 35 | -------------------------------------------------------------------------------- /arrow/memory/_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | cmake_minimum_required(VERSION 3.6) 18 | 19 | project(memory-func) 20 | set(CMAKE_C_STANDARD 99) 21 | 22 | add_library(memory STATIC memory.c) 23 | -------------------------------------------------------------------------------- /odps/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | /* 18 | 1. 所有GetXX类方法都会返回(XX, error), 注意错误判断 19 | 2. 所有需要从后台加载数据的Model(Project, Instance, Table..),在取属性前要调用XXX.Load()方法 20 | */ 21 | 22 | package odps 23 | -------------------------------------------------------------------------------- /arrow/Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | [[constraint]] 18 | name = "github.com/stretchr/testify" 19 | version = "1.2.0" 20 | 21 | [[constraint]] 22 | name = "github.com/pkg/errors" 23 | version = "0.8.1" -------------------------------------------------------------------------------- /arrow/memory/cgo_allocator_logging.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build cgo && ccalloc && cclog 18 | // +build cgo,ccalloc,cclog 19 | 20 | package memory 21 | 22 | const enableLogging = true 23 | -------------------------------------------------------------------------------- /arrow/math/_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | cmake_minimum_required(VERSION 3.6) 18 | 19 | project(math-func) 20 | set(CMAKE_C_STANDARD 99) 21 | 22 | add_library(memory STATIC float64.c int64.c uint64.c) 23 | -------------------------------------------------------------------------------- /arrow/math/type_noasm.go.tmpl: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // +build noasm 18 | 19 | package math 20 | 21 | {{with .In}} 22 | func init{{.Name}}Go() { 23 | {{.Name}}.sum = sum_{{.Type}}_go 24 | } 25 | {{end}} -------------------------------------------------------------------------------- /arrow/memory/cgo_allocator_defaults.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build cgo && ccalloc && !cclog 18 | // +build cgo,ccalloc,!cclog 19 | 20 | package memory 21 | 22 | const enableLogging = false 23 | -------------------------------------------------------------------------------- /arrow/math/type_s390x.go.tmpl: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // +build !noasm 18 | 19 | package math 20 | 21 | {{with .In}} 22 | func init{{.Name}}Go() { 23 | {{.Name}}.sum = sum_{{.Type}}_go 24 | } 25 | {{end}} 26 | -------------------------------------------------------------------------------- /examples/sdk/function/create_function/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | odpsIns.SetCurrentSchemaName("default") 23 | 24 | fb := odps.NewFunctionBuilder() 25 | fb.Name("test_sleep2") 26 | fb.ClassPath("org.example.Sleep") 27 | fb.Resources([]string{"udf-1.0-SNAPSHOT.jar"}) 28 | f := fb.Build() 29 | 30 | functions := odps.NewFunctions(odpsIns) 31 | err = functions.Create("", "", f) 32 | if err != nil { 33 | panic(err) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/sdk/security_manager/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/security" 10 | ) 11 | 12 | func main() { 13 | // Specify the ini file path 14 | configPath := "./config.ini" 15 | conf, err := odps.NewConfigFromIni(configPath) 16 | if err != nil { 17 | log.Fatalf("%+v", err) 18 | } 19 | 20 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 21 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 22 | // Set the Default Maxcompute project used By Odps instance 23 | odpsIns.SetDefaultProjectName(conf.ProjectName) 24 | 25 | restClient := odpsIns.RestClient() 26 | 27 | sm := security.NewSecurityManager(restClient, conf.ProjectName) 28 | result, err := sm.RunQuery("desc role role_project_admin;", true, "") 29 | if err != nil { 30 | log.Fatalf("%+v", err) 31 | } 32 | 33 | println(fmt.Sprintf("ok: %s", result)) 34 | } 35 | -------------------------------------------------------------------------------- /arrow/flight/gen.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package flight 18 | 19 | //go:generate protoc -I../../../format --go_out=. --go-grpc_out=. --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative Flight.proto 20 | -------------------------------------------------------------------------------- /examples/sdk/resources/list_resources/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | odpsIns.SetCurrentSchemaName("default") 24 | resources := odps.NewResources(odpsIns) 25 | 26 | resources.List(func(resource *odps.Resource, err error) { 27 | if err != nil { 28 | log.Fatalf("%+v", err) 29 | } 30 | fmt.Printf("%+v\n", resource) 31 | }) 32 | 33 | resource1 := resources.Get("bank_customer.txt") 34 | fmt.Println(resource1.Exist()) 35 | } 36 | -------------------------------------------------------------------------------- /arrow/endian/big.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build s390x 18 | // +build s390x 19 | 20 | package endian 21 | 22 | import "encoding/binary" 23 | 24 | var Native = binary.BigEndian 25 | 26 | const IsBigEndian = true 27 | -------------------------------------------------------------------------------- /examples/sdk/tunnel/init_tunnel/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/tunnel" 10 | ) 11 | 12 | func main() { 13 | // Get config from ini file 14 | conf, err := odps.NewConfigFromIni("./config.ini") 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | // Initialize Odps 20 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 21 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | project := odpsIns.DefaultProject() 24 | 25 | // Get the endpoint of tunnel service 26 | tunnelEndpoint, err := project.GetTunnelEndpoint() 27 | if err != nil { 28 | log.Fatalf("%+v", err) 29 | } 30 | fmt.Println("tunnel endpoint: " + tunnelEndpoint) 31 | 32 | // Initialize Tunnel 33 | tunnelIns := tunnel.NewTunnel(odpsIns, tunnelEndpoint) 34 | 35 | println("%+v", tunnelIns) 36 | } 37 | -------------------------------------------------------------------------------- /arrow/endian/little.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !s390x 18 | // +build !s390x 19 | 20 | package endian 21 | 22 | import "encoding/binary" 23 | 24 | var Native = binary.LittleEndian 25 | 26 | var IsBigEndian = false 27 | -------------------------------------------------------------------------------- /arrow/internal/testing/tools/bool.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package tools 18 | 19 | func Bools(v ...int) []bool { 20 | res := make([]bool, len(v)) 21 | for i, b := range v { 22 | res[i] = b != 0 23 | } 24 | return res 25 | } 26 | -------------------------------------------------------------------------------- /arrow/csv/testdata/simple.csv: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | # 18 | ## a simple set of data: int64;float64;string 19 | 0;0;str-0 20 | 1;1;str-1 21 | 2;2;str-2 22 | 3;3;str-3 23 | 4;4;str-4 24 | 5;5;str-5 25 | 6;6;str-6 26 | 7;7;str-7 27 | 8;8;str-8 28 | 9;9;str-9 29 | -------------------------------------------------------------------------------- /examples/sdk/resources/update_resource/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "os" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | odpsIns.SetCurrentSchemaName("default") 24 | resources := odps.NewResources(odpsIns) 25 | 26 | file, err := os.Open("xxxx") 27 | if err != nil { 28 | log.Fatal(err) 29 | } 30 | defer file.Close() 31 | 32 | fr := odps.NewFileResource("bank_data") 33 | fr.SetReader(file) 34 | 35 | err = resources.UpdateFileResource("", "", fr) 36 | if err != nil { 37 | log.Fatal(err) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /odps/tunnel/const.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package tunnel 18 | 19 | import "time" 20 | 21 | const ( 22 | DateTransformVersion = "v1" 23 | Version = "5" 24 | DefaultTcpConnectionTimeout = 10 * time.Second 25 | ) 26 | -------------------------------------------------------------------------------- /arrow/csv/testdata/header.csv: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | # 18 | bool;i8;i16;i32;i64;u8;u16;u32;u64;f32;f64;str 19 | true;-1;-1;-1;-1;1;1;1;1;1.1;1.1;str-1 20 | false;-2;-2;-2;-2;2;2;2;2;2.2;2.2;str-2 21 | null;null;null;null;null;null;null;null;null;null;null;null 22 | -------------------------------------------------------------------------------- /arrow/math/int64_arm64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_s390x.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | func initInt64Go() { 25 | Int64.sum = sum_int64_go 26 | } 27 | -------------------------------------------------------------------------------- /arrow/math/int64_noasm.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_noasm.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build noasm 20 | // +build noasm 21 | 22 | package math 23 | 24 | func initInt64Go() { 25 | Int64.sum = sum_int64_go 26 | } 27 | -------------------------------------------------------------------------------- /arrow/math/int64_s390x.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_s390x.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | func initInt64Go() { 25 | Int64.sum = sum_int64_go 26 | } 27 | -------------------------------------------------------------------------------- /arrow/math/uint64_noasm.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_noasm.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build noasm 20 | // +build noasm 21 | 22 | package math 23 | 24 | func initUint64Go() { 25 | Uint64.sum = sum_uint64_go 26 | } 27 | -------------------------------------------------------------------------------- /examples/sdk/instance/get_instance/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | 24 | ins := odpsIns.Instances().Get("2024101103485529ghlbgu6i4gg") 25 | err = ins.Load() 26 | if err != nil { 27 | log.Fatalf("%+v", err) 28 | } 29 | 30 | fmt.Printf("owner=%s\n", ins.Owner()) 31 | fmt.Printf("status=%s\n", ins.Status()) 32 | fmt.Printf("startTime=%s\n", ins.StartTime()) 33 | fmt.Printf("endTime=%s\n", ins.EndTime()) 34 | fmt.Printf("result=%+v\n", ins.TaskResults()) 35 | } 36 | -------------------------------------------------------------------------------- /arrow/math/float64_noasm.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_noasm.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build noasm 20 | // +build noasm 21 | 22 | package math 23 | 24 | func initFloat64Go() { 25 | Float64.sum = sum_float64_go 26 | } 27 | -------------------------------------------------------------------------------- /arrow/math/math_noasm.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build noasm 18 | // +build noasm 19 | 20 | package math 21 | 22 | func init() { 23 | initGo() 24 | } 25 | 26 | func initGo() { 27 | initFloat64Go() 28 | initInt64Go() 29 | initUint64Go() 30 | } 31 | -------------------------------------------------------------------------------- /arrow/math/uint64_arm64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_s390x.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | func initUint64Go() { 25 | Uint64.sum = sum_uint64_go 26 | } 27 | -------------------------------------------------------------------------------- /arrow/math/uint64_s390x.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_s390x.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | func initUint64Go() { 25 | Uint64.sum = sum_uint64_go 26 | } 27 | -------------------------------------------------------------------------------- /arrow/math/float64_arm64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_s390x.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | func initFloat64Go() { 25 | Float64.sum = sum_float64_go 26 | } 27 | -------------------------------------------------------------------------------- /arrow/math/float64_s390x.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_s390x.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | func initFloat64Go() { 25 | Float64.sum = sum_float64_go 26 | } 27 | -------------------------------------------------------------------------------- /arrow/math/math_arm64.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !noasm 18 | // +build !noasm 19 | 20 | package math 21 | 22 | func init() { 23 | initGo() 24 | } 25 | 26 | func initGo() { 27 | initFloat64Go() 28 | initInt64Go() 29 | initUint64Go() 30 | } 31 | -------------------------------------------------------------------------------- /arrow/math/math_s390x.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !noasm 18 | // +build !noasm 19 | 20 | package math 21 | 22 | func init() { 23 | initGo() 24 | } 25 | 26 | func initGo() { 27 | initFloat64Go() 28 | initInt64Go() 29 | initUint64Go() 30 | } 31 | -------------------------------------------------------------------------------- /examples/sdk/table/table_size/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("all_types_demo") 26 | 27 | err = table.Load() 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | 32 | // Get table size in bytes 33 | size := table.Size() 34 | println("size = ", size) 35 | 36 | // Get table rows count 37 | rowCount := table.RecordNum() 38 | println("rowCount = ", rowCount) 39 | } 40 | -------------------------------------------------------------------------------- /examples/sdk/partition/get_partition/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | 24 | project := odpsIns.Project(conf.ProjectName) 25 | tables := project.Tables() 26 | table := tables.Get("all_types_demo") 27 | 28 | p, err := table.GetPartition("p1=20/p2=hangzhou") 29 | if err != nil { 30 | log.Fatalf("%+v", err) 31 | } 32 | 33 | fmt.Printf( 34 | "value=%s, lastDDLTime=%s, lastModifiedTime=%s, size=%d\n", 35 | p.Value(), p.LastDDLTime(), p.LastModifiedTime(), p.Size(), 36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /examples/sdk/function/update_function/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | odpsIns.SetCurrentSchemaName("default") 23 | 24 | fb := odps.NewFunctionBuilder() 25 | fb.Name("test_sleep2") 26 | fb.ClassPath("com.aliyun.odps.observation.udf.jobinsight.Base64Decoder") 27 | fb.Resources([]string{"mc-observation-miscellaneous-1.0-SNAPSHOT.jar"}) 28 | f := fb.Build() 29 | 30 | functions := odps.NewFunctions(odpsIns) 31 | err = functions.Update("", "", f) 32 | if err != nil { 33 | panic(err) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/sdk/resources/create_resource/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "os" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | odpsIns.SetCurrentSchemaName("default") 24 | resources := odps.NewResources(odpsIns) 25 | 26 | file, err := os.Open("xxxx/test_resource.jar") 27 | if err != nil { 28 | log.Fatal(err) 29 | } 30 | defer file.Close() 31 | 32 | fr := odps.NewJarResource("test_resource.jar") 33 | fr.SetReader(file) 34 | 35 | err = resources.CreateFileResource("", "", fr, false) 36 | if err != nil { 37 | log.Fatal(err) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /arrow/csv/testdata/types.csv: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | # 18 | ## supported types: bool;int8;int16;int32;int64;uint8;uint16;uint32;uint64;float32;float64;string 19 | true;-1;-1;-1;-1;1;1;1;1;1.1;1.1;str-1 20 | false;-2;-2;-2;-2;2;2;2;2;2.2;2.2;str-2 21 | null;NULL;null;N/A;;null;null;null;null;null;null;null 22 | -------------------------------------------------------------------------------- /arrow/math/_lib/float64.c: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | #include 18 | #include 19 | 20 | void FULL_NAME(sum_float64)(double buf[], size_t len, double *res) { 21 | double acc = 0.0; 22 | for(int i = 0; i < len; i++) { 23 | acc += buf[i]; 24 | } 25 | *res = acc; 26 | } -------------------------------------------------------------------------------- /odps/common/result.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package common 18 | 19 | type Result struct { 20 | Data interface{} 21 | Error error 22 | } 23 | 24 | func (r *Result) IsOk() bool { 25 | return r.Error == nil 26 | } 27 | 28 | func (r *Result) IsErr() bool { 29 | return r.Error != nil 30 | } 31 | -------------------------------------------------------------------------------- /odps/data/json.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | 7 | "github.com/pkg/errors" 8 | 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/datatype" 10 | ) 11 | 12 | type Json struct { 13 | Data string 14 | Valid bool 15 | } 16 | 17 | func NewJson(value interface{}) (*Json, error) { 18 | byteArr, err := json.Marshal(value) 19 | if err != nil { 20 | return nil, err 21 | } 22 | d := string(byteArr) 23 | 24 | return &Json{ 25 | Data: d, 26 | Valid: true, 27 | }, nil 28 | } 29 | 30 | func (j Json) Type() datatype.DataType { 31 | return datatype.JsonType{} 32 | } 33 | 34 | func (j Json) String() string { 35 | var sb strings.Builder 36 | sb.WriteString(j.Data) 37 | 38 | return sb.String() 39 | } 40 | 41 | func (j Json) Sql() string { 42 | var sb strings.Builder 43 | sb.WriteString("JSON'") 44 | sb.WriteString(j.Data) 45 | sb.WriteString("'") 46 | 47 | return sb.String() 48 | } 49 | 50 | func (j *Json) Scan(value interface{}) error { 51 | return errors.WithStack(tryConvertType(value, j)) 52 | } 53 | 54 | func (j *Json) GetData() string { 55 | return j.Data 56 | } 57 | -------------------------------------------------------------------------------- /arrow/internal/debug/assert_off.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !assert 18 | // +build !assert 19 | 20 | package debug 21 | 22 | // Assert will panic with msg if cond is false. 23 | // 24 | // msg must be a string, func() string or fmt.Stringer. 25 | func Assert(cond bool, msg interface{}) {} 26 | -------------------------------------------------------------------------------- /arrow/memory/_lib/memory.c: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | #include "arch.h" 18 | #include 19 | 20 | void FULL_NAME(memset)(void *buf, size_t len, int v) { 21 | char *bytes = buf; 22 | char *end = buf+len; 23 | const char val = v; 24 | while (bytes < end) { 25 | *bytes++ = val; 26 | } 27 | } -------------------------------------------------------------------------------- /examples/sdk/table/list_tables/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | ts := project.Tables() 25 | 26 | ts.List( 27 | func(t *odps.Table, err error) { 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | 32 | println(t.Name()) 33 | }, 34 | // Filter tables by name prefix 35 | odps.TableFilter.NamePrefix("test_cluster"), 36 | // Filter tables by table type. Other table types are: VirtualView, ExternalTable 37 | odps.TableFilter.Type(odps.ManagedTable), 38 | ) 39 | } 40 | -------------------------------------------------------------------------------- /arrow/math/_lib/arch.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | #undef FULL_NAME 18 | 19 | #if defined(__AVX2__) 20 | #define FULL_NAME(x) x##_avx2 21 | #elif __SSE4_2__ == 1 22 | #define FULL_NAME(x) x##_sse4 23 | #elif __SSE3__ == 1 24 | #define FULL_NAME(x) x##_sse3 25 | #else 26 | #define FULL_NAME(x) x##_x86 27 | #endif -------------------------------------------------------------------------------- /arrow/math/_lib/int64.c: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | void FULL_NAME(sum_int64)(int64_t buf[], size_t len, int64_t *res) { 22 | int64_t acc = 0; 23 | for(int i = 0; i < len; i++) { 24 | acc += buf[i]; 25 | } 26 | *res = acc; 27 | } -------------------------------------------------------------------------------- /arrow/memory/_lib/arch.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | #undef FULL_NAME 18 | 19 | #if defined(__AVX2__) 20 | #define FULL_NAME(x) x##_avx2 21 | #elif __SSE4_2__ == 1 22 | #define FULL_NAME(x) x##_sse4 23 | #elif __SSE3__ == 1 24 | #define FULL_NAME(x) x##_sse3 25 | #else 26 | #define FULL_NAME(x) x##_x86 27 | #endif -------------------------------------------------------------------------------- /arrow/math/_lib/uint64.c: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | void FULL_NAME(sum_uint64)(uint64_t buf[], size_t len, uint64_t *res) { 22 | uint64_t acc = 0; 23 | for(int i = 0; i < len; i++) { 24 | acc += buf[i]; 25 | } 26 | *res = acc; 27 | } -------------------------------------------------------------------------------- /arrow/internal/debug/log_on.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build debug 18 | // +build debug 19 | 20 | package debug 21 | 22 | import ( 23 | "log" 24 | "os" 25 | ) 26 | 27 | var ( 28 | debug = log.New(os.Stderr, "[D] ", log.LstdFlags) 29 | ) 30 | 31 | func Log(msg interface{}) { 32 | debug.Output(1, getStringValue(msg)) 33 | } 34 | -------------------------------------------------------------------------------- /examples/sdk/aliyun_credential/use_ak/use_ak_from_env/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aliyun/credentials-go/credentials" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 10 | ) 11 | 12 | func main() { 13 | // Read ak from environment variables: "ALIBABA_CLOUD_ACCESS_KEY_ID", "ALIBABA_CLOUD_ACCESS_KEY_SECRET" 14 | credential, err := credentials.NewCredential(nil) 15 | if err != nil { 16 | return 17 | } 18 | 19 | aliyunAccount := account.NewStsAccountWithCredential(credential) 20 | // Get the endpoint of a specific region from https://www.alibabacloud.com/help/en/maxcompute/user-guide/endpoints 21 | // 获取具体的endpoint请参考 https://help.aliyun.com/zh/maxcompute/user-guide/endpoints 22 | // The following an example endpoint of cn-hangzhou 23 | endpoint := "http://service.cn-hangzhou.maxcompute.aliyun.com/api" 24 | 25 | // The Default Maxcompute project used by Odps instance 26 | defaultProject := "" 27 | 28 | odpsIns := odps.NewOdps(aliyunAccount, endpoint) 29 | odpsIns.SetDefaultProjectName(defaultProject) 30 | 31 | fmt.Printf("odps:%#v\n", odpsIns) 32 | } 33 | -------------------------------------------------------------------------------- /arrow/internal/debug/assert_on.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build assert 18 | // +build assert 19 | 20 | package debug 21 | 22 | // Assert will panic with msg if cond is false. 23 | // 24 | // msg must be a string, func() string or fmt.Stringer. 25 | func Assert(cond bool, msg interface{}) { 26 | if !cond { 27 | panic(getStringValue(msg)) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/sdk/aliyun_credential/use_sts_token/use_sts_from_credentials_uri/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aliyun/credentials-go/credentials" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 10 | ) 11 | 12 | func main() { 13 | config := new(credentials.Config).SetType("credentials_uri").SetURLCredential("http://127.0.0.1") 14 | credential, err := credentials.NewCredential(config) 15 | if err != nil { 16 | return 17 | } 18 | 19 | stsAccount := account.NewStsAccountWithCredential(credential) 20 | 21 | // Get the endpoint of a specific region from https://www.alibabacloud.com/help/en/maxcompute/user-guide/endpoints 22 | // 获取具体的endpoint请参考 https://help.aliyun.com/zh/maxcompute/user-guide/endpoints 23 | // The following an example endpoint of cn-hangzhou 24 | endpoint := "http://service.cn-hangzhou.maxcompute.aliyun.com/api" 25 | 26 | // The Default Maxcompute project used by Odps instance 27 | defaultProject := "" 28 | 29 | odpsIns := odps.NewOdps(stsAccount, endpoint) 30 | odpsIns.SetDefaultProjectName(defaultProject) 31 | 32 | fmt.Printf("odps:%#v\n", odpsIns) 33 | } 34 | -------------------------------------------------------------------------------- /arrow/bitutil/endian_s390x.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package bitutil 18 | 19 | import ( 20 | "math/bits" 21 | "unsafe" 22 | ) 23 | 24 | var toFromLEFunc = bits.ReverseBytes64 25 | 26 | func getLSB(v uint64) byte { 27 | return (*[8]byte)(unsafe.Pointer(&v))[7] 28 | } 29 | 30 | func setLSB(v *uint64, b byte) { 31 | (*[8]byte)(unsafe.Pointer(v))[7] = b 32 | } 33 | -------------------------------------------------------------------------------- /examples/sdk/create_table_with_json_column/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/datatype" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/tableschema" 10 | ) 11 | 12 | func main() { 13 | conf, err := odps.NewConfigFromIni("./config.ini") 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | odpsIns.SetDefaultProjectName(conf.ProjectName) 21 | 22 | c1 := tableschema.Column{ 23 | Name: "name", 24 | Type: datatype.NewJsonType(), 25 | } 26 | 27 | println(c1.Type.Name()) 28 | 29 | schemaBuilder := tableschema.NewSchemaBuilder() 30 | schemaBuilder.Name("test_json"). 31 | Columns(c1). 32 | Comment("test for table creation with golang sdk"). 33 | Lifecycle(2) 34 | 35 | schema := schemaBuilder.Build() 36 | tablesIns := odpsIns.Tables() 37 | err = tablesIns.Create(schema, false, conf.Hints, nil) 38 | if err != nil { 39 | log.Fatalf("%+v", err) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /arrow/math/type_amd64.go.tmpl: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // +build !noasm 18 | 19 | package math 20 | 21 | {{with .In}} 22 | func init{{.Name}}AVX2() { 23 | {{.Name}}.sum = sum_{{.Type}}_avx2 24 | } 25 | 26 | func init{{.Name}}SSE4() { 27 | {{.Name}}.sum = sum_{{.Type}}_sse4 28 | } 29 | 30 | func init{{.Name}}Go() { 31 | {{.Name}}.sum = sum_{{.Type}}_go 32 | } 33 | {{end}} -------------------------------------------------------------------------------- /examples/sdk/table/get_table_data_masking_policy/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | 24 | project := odpsIns.Project(conf.ProjectName) 25 | tables := project.Tables() 26 | table := tables.Get("personal_info") 27 | 28 | err = table.Load() 29 | if err != nil { 30 | log.Fatalf("%+v", err) 31 | } 32 | 33 | maskInfos, err := table.ColumnMaskInfos() 34 | if err != nil { 35 | log.Fatalf("%+v", err) 36 | } 37 | 38 | for _, maskInfo := range maskInfos { 39 | fmt.Println("column name = ", maskInfo.Name) 40 | fmt.Println("column policy name = ", maskInfo.PolicyNameList) 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /arrow/math/int64_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_amd64.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | func initInt64AVX2() { 25 | Int64.sum = sum_int64_avx2 26 | } 27 | 28 | func initInt64SSE4() { 29 | Int64.sum = sum_int64_sse4 30 | } 31 | 32 | func initInt64Go() { 33 | Int64.sum = sum_int64_go 34 | } 35 | -------------------------------------------------------------------------------- /examples/sdk/aliyun_credential/use_sts_token/use_sts_token_from_env/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aliyun/credentials-go/credentials" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 10 | ) 11 | 12 | func main() { 13 | // Read ak from environment variables: "ALIBABA_CLOUD_ACCESS_KEY_ID", 14 | // "ALIBABA_CLOUD_ACCESS_KEY_SECRET", "ALIBABA_CLOUD_SECURITY_TOKEN" 15 | credential, err := credentials.NewCredential(nil) 16 | if err != nil { 17 | return 18 | } 19 | 20 | aliyunAccount := account.NewStsAccountWithCredential(credential) 21 | 22 | // Get the endpoint of a specific region from https://www.alibabacloud.com/help/en/maxcompute/user-guide/endpoints 23 | // 获取具体的endpoint请参考 https://help.aliyun.com/zh/maxcompute/user-guide/endpoints 24 | // The following an example endpoint of cn-hangzhou 25 | endpoint := "http://service.cn-hangzhou.maxcompute.aliyun.com/api" 26 | 27 | // The Default Maxcompute project used by Odps instance 28 | defaultProject := "" 29 | 30 | odpsIns := odps.NewOdps(aliyunAccount, endpoint) 31 | odpsIns.SetDefaultProjectName(defaultProject) 32 | 33 | fmt.Printf("odps:%#v\n", odpsIns) 34 | } 35 | -------------------------------------------------------------------------------- /examples/sdk/partition/list_partitions/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | 24 | project := odpsIns.Project(conf.ProjectName) 25 | tables := project.Tables() 26 | table := tables.Get("all_types_demo") 27 | 28 | partitions, err := table.GetPartitions() 29 | if err != nil { 30 | log.Fatalf("%+v", err) 31 | } 32 | 33 | fmt.Printf("get %d partitions\n", len(partitions)) 34 | 35 | for _, p := range partitions { 36 | fmt.Printf( 37 | "value=%s, createTime=%s, lastDDLTime=%s, lastModifiedTime=%s, size=%d\n", 38 | p.Value(), p.CreatedTime(), p.LastDDLTime(), p.LastModifiedTime(), p.Size(), 39 | ) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /arrow/math/uint64_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_amd64.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | func initUint64AVX2() { 25 | Uint64.sum = sum_uint64_avx2 26 | } 27 | 28 | func initUint64SSE4() { 29 | Uint64.sum = sum_uint64_sse4 30 | } 31 | 32 | func initUint64Go() { 33 | Uint64.sum = sum_uint64_go 34 | } 35 | -------------------------------------------------------------------------------- /arrow/bitutil/endian_default.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !s390x 18 | // +build !s390x 19 | 20 | package bitutil 21 | 22 | import ( 23 | "unsafe" 24 | ) 25 | 26 | var toFromLEFunc = func(in uint64) uint64 { return in } 27 | 28 | func getLSB(v uint64) byte { 29 | return (*[8]byte)(unsafe.Pointer(&v))[0] 30 | } 31 | 32 | func setLSB(v *uint64, b byte) { 33 | (*[8]byte)(unsafe.Pointer(v))[0] = b 34 | } 35 | -------------------------------------------------------------------------------- /arrow/math/float64_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_amd64.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | func initFloat64AVX2() { 25 | Float64.sum = sum_float64_avx2 26 | } 27 | 28 | func initFloat64SSE4() { 29 | Float64.sum = sum_float64_sse4 30 | } 31 | 32 | func initFloat64Go() { 33 | Float64.sum = sum_float64_go 34 | } 35 | -------------------------------------------------------------------------------- /arrow/memory/memory_sse4_amd64.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !noasm 18 | // +build !noasm 19 | 20 | package memory 21 | 22 | import "unsafe" 23 | 24 | //go:noescape 25 | func _memset_sse4(buf unsafe.Pointer, len, c uintptr) 26 | 27 | func memory_memset_sse4(buf []byte, c byte) { 28 | if len(buf) == 0 { 29 | return 30 | } 31 | _memset_sse4(unsafe.Pointer(&buf[0]), uintptr(len(buf)), uintptr(c)) 32 | } 33 | -------------------------------------------------------------------------------- /arrow/type_traits_boolean.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package arrow 18 | 19 | import ( 20 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/bitutil" 21 | ) 22 | 23 | type booleanTraits struct{} 24 | 25 | var BooleanTraits booleanTraits 26 | 27 | // BytesRequired returns the number of bytes required to store n elements in memory. 28 | func (booleanTraits) BytesRequired(n int) int { return bitutil.CeilByte(n) / 8 } 29 | -------------------------------------------------------------------------------- /odps/common/property.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package common 18 | 19 | type Property struct { 20 | Name string 21 | Value string 22 | } 23 | 24 | // Properties just alias to []Property 25 | type Properties []Property 26 | 27 | func (ps Properties) Get(key string) string { 28 | for _, p := range []Property(ps) { 29 | if p.Name == key { 30 | return p.Value 31 | } 32 | } 33 | 34 | return "" 35 | } 36 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml 2 | 3 | run: 4 | timeout: 5m 5 | modules-download-mode: readonly 6 | tests: false 7 | go: '1.15' 8 | 9 | linters: 10 | enable: 11 | - errcheck 12 | - goimports 13 | - revive 14 | - govet 15 | - staticcheck 16 | - gosimple 17 | disable: 18 | - unused 19 | 20 | issues: 21 | exclude-use-default: false 22 | max-issues-per-linter: 0 23 | max-same-issues: 0 24 | new-from-rev: master 25 | 26 | linters-settings: 27 | staticcheck: 28 | # SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks 29 | # Default value: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022"] 30 | checks: 31 | # default checks 32 | - "all" 33 | - "-ST1000" 34 | - "-ST1003" 35 | - "-ST1016" 36 | - "-ST1020" 37 | - "-ST1021" 38 | - "-ST1022" 39 | # other checks 40 | - "-SA1019" # Enable using a deprecated function, variable, constant or field. For compatibility reasons. 41 | goimports: 42 | local-prefixes: github.com/aliyun/aliyun-odps-go-sdk 43 | revive: 44 | rules: 45 | - name: var-naming 46 | disabled: true 47 | -------------------------------------------------------------------------------- /arrow/memory/memory_amd64.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !noasm 18 | // +build !noasm 19 | 20 | package memory 21 | 22 | import ( 23 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/internal/cpu" 24 | ) 25 | 26 | func init() { 27 | if cpu.X86.HasAVX2 { 28 | memset = memory_memset_avx2 29 | } else if cpu.X86.HasSSE42 { 30 | memset = memory_memset_sse4 31 | } else { 32 | memset = memory_memset_go 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # .github/workflows/release.yml 2 | name: goreleaser 3 | 4 | on: 5 | push: 6 | # run only against tags 7 | tags: 8 | - "*" 9 | 10 | permissions: 11 | contents: write 12 | # packages: write 13 | # issues: write 14 | # id-token: write 15 | 16 | jobs: 17 | goreleaser: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | with: 23 | fetch-depth: 0 24 | - name: Set up Go 25 | uses: actions/setup-go@v5 26 | with: 27 | go-version: stable 28 | # More assembly might be required: Docker logins, GPG, etc. 29 | # It all depends on your needs. 30 | - name: Run GoReleaser 31 | uses: goreleaser/goreleaser-action@v6 32 | with: 33 | # either 'goreleaser' (default) or 'goreleaser-pro' 34 | distribution: goreleaser 35 | # 'latest', 'nightly', or a semver 36 | version: "~> v2" 37 | args: release --clean 38 | env: 39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 | # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution 41 | # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} 42 | -------------------------------------------------------------------------------- /examples/sdk/table/get_table/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("all_types_demo") 26 | 27 | err = table.Load() 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | 32 | // Get table create time 33 | createTime := table.CreatedTime() 34 | println("create time = ", createTime) 35 | 36 | // Get table last ddl time 37 | lastDDLTime := table.LastDDLTime() 38 | println("last ddl time = ", lastDDLTime) 39 | 40 | // Get table last modified time 41 | lastModifiedTime := table.LastModifiedTime() 42 | println("last modified time = ", lastModifiedTime) 43 | } 44 | -------------------------------------------------------------------------------- /examples/sdk/table/table_time/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | project := odpsIns.Project(conf.ProjectName) 24 | tables := project.Tables() 25 | table := tables.Get("all_types_demo") 26 | 27 | err = table.Load() 28 | if err != nil { 29 | log.Fatalf("%+v", err) 30 | } 31 | 32 | // Get table create time 33 | createTime := table.CreatedTime() 34 | println("create time = ", createTime) 35 | 36 | // Get table last ddl time 37 | lastDDLTime := table.LastDDLTime() 38 | println("last ddl time = ", lastDDLTime) 39 | 40 | // Get table last modified time 41 | lastModifiedTime := table.LastModifiedTime() 42 | println("last modified time = ", lastModifiedTime) 43 | } 44 | -------------------------------------------------------------------------------- /arrow/datatype_numeric.gen.go.tmpldata: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Name": "Int8", 4 | "Type": "int8", 5 | "Size": 8 6 | }, 7 | { 8 | "Name": "Int16", 9 | "Type": "int16", 10 | "Size": 16 11 | }, 12 | { 13 | "Name": "Int32", 14 | "Type": "int32", 15 | "Size": 32 16 | }, 17 | { 18 | "Name": "Int64", 19 | "Type": "int64", 20 | "Size": 64 21 | }, 22 | { 23 | "Name": "Uint8", 24 | "Type": "uint8", 25 | "Size": 8 26 | }, 27 | { 28 | "Name": "Uint16", 29 | "Type": "uint16", 30 | "Size": 16 31 | }, 32 | { 33 | "Name": "Uint32", 34 | "Type": "uint32", 35 | "Size": 32 36 | }, 37 | { 38 | "Name": "Uint64", 39 | "Type": "uint64", 40 | "Size": 64 41 | }, 42 | { 43 | "Name": "Float32", 44 | "Type": "float32", 45 | "Size": 32 46 | }, 47 | { 48 | "Name": "Float64", 49 | "Type": "float64", 50 | "Size": 64 51 | }, 52 | { 53 | "Name": "Date32", 54 | "Type": "date32", 55 | "QualifiedType": "arrow.Date32", 56 | "InternalType": "int32", 57 | "Size": 32 58 | }, 59 | { 60 | "Name": "Date64", 61 | "Type": "date64", 62 | "QualifiedType": "arrow.Date64", 63 | "InternalType": "int64", 64 | "Size": 64 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /arrow/memory/memory.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package memory 18 | 19 | var ( 20 | memset func(b []byte, c byte) = memory_memset_go 21 | ) 22 | 23 | // Set assigns the value c to every element of the slice buf. 24 | func Set(buf []byte, c byte) { 25 | memset(buf, c) 26 | } 27 | 28 | // memory_memset_go reference implementation 29 | func memory_memset_go(buf []byte, c byte) { 30 | for i := 0; i < len(buf); i++ { 31 | buf[i] = c 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /arrow/internal/debug/util.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build debug || assert 18 | // +build debug assert 19 | 20 | package debug 21 | 22 | import "fmt" 23 | 24 | func getStringValue(v interface{}) string { 25 | switch a := v.(type) { 26 | case func() string: 27 | return a() 28 | 29 | case string: 30 | return a 31 | 32 | case fmt.Stringer: 33 | return a.String() 34 | 35 | default: 36 | panic(fmt.Sprintf("unexpected type, %t", v)) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/sdk/logview/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | ) 9 | 10 | func main() { 11 | // Specify the ini file path 12 | configPath := "./config.ini" 13 | conf, err := odps.NewConfigFromIni(configPath) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 19 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 20 | // Set the Default Maxcompute project used By Odps instance 21 | odpsIns.SetDefaultProjectName(conf.ProjectName) 22 | 23 | sql := "select * from all_types_demo where p1>0 or p2 > '';" 24 | 25 | // The flags used by sql engine, such as odps.sql.skewjoin 26 | var hints map[string]string = nil 27 | 28 | // Create a SqlTask 29 | sqlTask := odps.NewSqlTask("select", sql, hints) 30 | 31 | // Run the sql with the quota associated with a project 32 | project := odpsIns.DefaultProjectName() 33 | ins, err := sqlTask.Run(odpsIns, project) 34 | if err != nil { 35 | log.Fatalf("%+v", err) 36 | } 37 | 38 | logView, err := odpsIns.LogView().GenerateLogView(ins, 1) 39 | if err != nil { 40 | log.Fatalf("%+v", err) 41 | } 42 | 43 | println(logView) 44 | } 45 | -------------------------------------------------------------------------------- /arrow/datatype_null.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package arrow 18 | 19 | // NullType describes a degenerate array, with zero physical storage. 20 | type NullType struct{} 21 | 22 | func (*NullType) ID() Type { return NULL } 23 | func (*NullType) Name() string { return "null" } 24 | func (*NullType) String() string { return "null" } 25 | func (*NullType) Fingerprint() string { return typeIDFingerprint(NULL) } 26 | 27 | var ( 28 | Null *NullType 29 | _ DataType = Null 30 | ) 31 | -------------------------------------------------------------------------------- /arrow/memory/allocator.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package memory 18 | 19 | const ( 20 | alignment = 64 21 | ) 22 | 23 | type Allocator interface { 24 | Allocate(size int) []byte 25 | Reallocate(size int, b []byte) []byte 26 | Free(b []byte) 27 | } 28 | 29 | // DefaultAllocator is a default implementation of Allocator and can be used anywhere 30 | // an Allocator is required. 31 | // 32 | // DefaultAllocator is safe to use from multiple goroutines. 33 | var DefaultAllocator Allocator = NewGoAllocator() 34 | -------------------------------------------------------------------------------- /sqldriver/driver.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package sqldriver 18 | 19 | import ( 20 | "database/sql" 21 | "database/sql/driver" 22 | 23 | "github.com/pkg/errors" 24 | ) 25 | 26 | func init() { 27 | sql.Register("odps", &OdpsDriver{}) 28 | } 29 | 30 | type OdpsDriver struct{} 31 | 32 | func (d OdpsDriver) Open(name string) (driver.Conn, error) { 33 | config, err := ParseDSN(name) 34 | if err != nil { 35 | return nil, errors.WithStack(err) 36 | } 37 | 38 | return newConnection(config), nil 39 | } 40 | -------------------------------------------------------------------------------- /arrow/_examples/helloworld/main.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 22 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/math" 23 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/memory" 24 | ) 25 | 26 | func main() { 27 | fb := array.NewFloat64Builder(memory.DefaultAllocator) 28 | 29 | fb.AppendValues([]float64{1, 3, 5, 7, 9, 11}, nil) 30 | 31 | vec := fb.NewFloat64Array() 32 | fmt.Println(math.Float64.Sum(vec)) 33 | } 34 | -------------------------------------------------------------------------------- /odps/data/null.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package data 18 | 19 | import ( 20 | "github.com/aliyun/aliyun-odps-go-sdk/odps/datatype" 21 | ) 22 | 23 | type NullData struct{} 24 | 25 | var Null = NullData{} 26 | 27 | func (n NullData) Type() datatype.DataType { 28 | return datatype.NullType 29 | } 30 | 31 | func (n NullData) String() string { 32 | return "NULL" 33 | } 34 | 35 | func (n NullData) Sql() string { 36 | return "NULL" 37 | } 38 | 39 | func (n NullData) Scan(interface{}) error { 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /arrow/array/bufferbuilder_byte.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package array 18 | 19 | import "github.com/aliyun/aliyun-odps-go-sdk/arrow/memory" 20 | 21 | type byteBufferBuilder struct { 22 | bufferBuilder 23 | } 24 | 25 | func newByteBufferBuilder(mem memory.Allocator) *byteBufferBuilder { 26 | return &byteBufferBuilder{bufferBuilder: bufferBuilder{refCount: 1, mem: mem}} 27 | } 28 | 29 | func (b *byteBufferBuilder) Values() []byte { return b.Bytes() } 30 | func (b *byteBufferBuilder) Value(i int) byte { return b.bytes[i] } 31 | -------------------------------------------------------------------------------- /arrow/memory/util.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package memory 18 | 19 | import "unsafe" 20 | 21 | func roundToPowerOf2(v, round int) int { 22 | forceCarry := round - 1 23 | truncateMask := ^forceCarry 24 | return (v + forceCarry) & truncateMask 25 | } 26 | 27 | func roundUpToMultipleOf64(v int) int { 28 | return roundToPowerOf2(v, 64) 29 | } 30 | 31 | func isMultipleOfPowerOf2(v int, d int) bool { 32 | return (v & (d - 1)) == 0 33 | } 34 | 35 | func addressOf(b []byte) uintptr { 36 | return uintptr(unsafe.Pointer(&b[0])) 37 | } 38 | -------------------------------------------------------------------------------- /odps/tunnel/protoc_common.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package tunnel 18 | 19 | import ( 20 | "time" 21 | 22 | "google.golang.org/protobuf/encoding/protowire" 23 | ) 24 | 25 | var epochDay time.Time 26 | 27 | func init() { 28 | epochDay, _ = time.ParseInLocation("2006-01-02", "1970-01-01", time.UTC) 29 | } 30 | 31 | const ( 32 | MetaCount = protowire.Number(33554430) // magic num 2^25-2 33 | MetaChecksum = protowire.Number(33554431) // magic num 2^25-1 34 | EndRecord = protowire.Number(33553408) // magic num 2^25-1024 35 | ) 36 | -------------------------------------------------------------------------------- /arrow/internal/debug/doc.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | /* 18 | Package debug provides APIs for conditional runtime assertions and debug logging. 19 | 20 | 21 | Using Assert 22 | 23 | To enable runtime assertions, build with the assert tag. When the assert tag is omitted, 24 | the code for the assertion will be omitted from the binary. 25 | 26 | 27 | Using Log 28 | 29 | To enable runtime debug logs, build with the debug tag. When the debug tag is omitted, 30 | the code for logging will be omitted from the binary. 31 | */ 32 | package debug 33 | -------------------------------------------------------------------------------- /examples/sdk/instance/list_instances/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "time" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 10 | ) 11 | 12 | func main() { 13 | // Specify the ini file path 14 | configPath := "./config.ini" 15 | conf, err := odps.NewConfigFromIni(configPath) 16 | if err != nil { 17 | log.Fatalf("%+v", err) 18 | } 19 | 20 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 21 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 22 | // Set the Default Maxcompute project used By Odps instance 23 | odpsIns.SetDefaultProjectName(conf.ProjectName) 24 | 25 | timeFormat := "2006-01-02 15:04:05" 26 | startTime, _ := time.Parse(timeFormat, "2024-10-11 02:15:30") 27 | endTime, _ := time.Parse(timeFormat, "2024-10-13 06:22:02") 28 | 29 | f := func(i *odps.Instance) { 30 | if err != nil { 31 | log.Fatalf("%+v", err) 32 | } 33 | 34 | println( 35 | fmt.Sprintf( 36 | "%s, %s, %s, %s, %s", 37 | i.Id(), i.Owner(), i.StartTime().Format(timeFormat), i.EndTime().Format(timeFormat), i.Status(), 38 | )) 39 | } 40 | 41 | instances := odpsIns.Instances() 42 | instances.List( 43 | f, 44 | odps.InstanceFilter.TimeRange(startTime, endTime), 45 | odps.InstanceFilter.Status(odps.InstanceTerminated), 46 | ) 47 | } 48 | -------------------------------------------------------------------------------- /examples/sql/insert_data/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "log" 6 | "os" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/data" 9 | "github.com/aliyun/aliyun-odps-go-sdk/sqldriver" 10 | ) 11 | 12 | func main() { 13 | config, err := sqldriver.NewConfigFromIni(os.Args[1]) 14 | if err != nil { 15 | log.Fatalf("%+v", err) 16 | } 17 | 18 | dsn := config.FormatDsn() 19 | // or dsn := "http://:@?project=" 20 | 21 | db, err := sql.Open("odps", dsn) 22 | if err != nil { 23 | log.Fatalf("%+v", err) 24 | } 25 | 26 | insertSql := "insert into user_test partition (age=20, hometown='hangzhou') values (" + 27 | "@name, @score, @birthday, @extra);" 28 | 29 | birthday, _ := data.NewDateTime("2010-11-11 15:20:00") 30 | addresses := data.NewArray() 31 | _ = addresses.Append("apsaras", "efc") 32 | extra := data.NewStruct() 33 | _ = extra.SetField("address", addresses) 34 | _ = extra.SetField("hobby", "swimming") 35 | 36 | _, err = db.Exec( 37 | insertSql, 38 | sql.Named("name", "'xiaoming'"), 39 | sql.Named("score", 99), 40 | sql.Named("birthday", birthday.Sql()), // datetime'2010-11-11 15:20:00' 41 | sql.Named("extra", extra.Sql()), // named_struct('address', array('apsaras', 'efc'), 'hobby', 'swimming') 42 | ) 43 | if err != nil { 44 | log.Fatalf("%+v", err) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /odps/tunnel/session_config_schema_test.go: -------------------------------------------------------------------------------- 1 | package tunnel_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps/tunnel" 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | // TestSessionConfigWithSchemaName tests that the session configuration 11 | // properly handles schema names through options 12 | func TestSessionConfigWithSchemaName(t *testing.T) { 13 | // Test that SessionCfg.WithSchemaName creates a valid option 14 | schemaName := "test-schema" 15 | option := tunnel.SessionCfg.WithSchemaName(schemaName) 16 | 17 | assert.NotNil(t, option) 18 | // We can't directly test the internal config since newSessionConfig is not exported 19 | // But we can verify the option is created successfully 20 | } 21 | 22 | // TestSessionConfigMultipleOptions tests that the session configuration 23 | // properly handles multiple options including schema name 24 | func TestSessionConfigMultipleOptions(t *testing.T) { 25 | schemaName := "test-schema" 26 | partitionKey := "p1='test'" 27 | 28 | // Test that all options can be created successfully 29 | option1 := tunnel.SessionCfg.WithSchemaName(schemaName) 30 | option2 := tunnel.SessionCfg.WithPartitionKey(partitionKey) 31 | option3 := tunnel.SessionCfg.WithDefaultDeflateCompressor() 32 | 33 | assert.NotNil(t, option1) 34 | assert.NotNil(t, option2) 35 | assert.NotNil(t, option3) 36 | } 37 | -------------------------------------------------------------------------------- /odps/restclient/rest_client_test.go: -------------------------------------------------------------------------------- 1 | package restclient 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "net/url" 7 | "testing" 8 | 9 | "github.com/stretchr/testify/assert" 10 | 11 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 12 | ) 13 | 14 | // MockAccount 实现 account.Account 接口 15 | type MockAccount struct{} 16 | 17 | func (a MockAccount) SignRequest(req *http.Request, endpoint string) error { 18 | req.Header.Set("Authorization", "MockToken") 19 | return nil 20 | } 21 | 22 | func (a MockAccount) GetType() account.Provider { 23 | return account.Aliyun 24 | } 25 | 26 | // 测试结构体 27 | type TestResponse struct { 28 | Message string `xml:"Message"` 29 | } 30 | 31 | func TestRestClient_GetWithModel_Success(t *testing.T) { 32 | // 创建模拟服务器 33 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 34 | assert.Equal(t, "/test", r.URL.Path) 35 | assert.Equal(t, "GET", r.Method) 36 | assert.Equal(t, "MockToken", r.Header.Get("Authorization")) 37 | 38 | w.WriteHeader(http.StatusOK) 39 | w.Write([]byte(`Hello`)) 40 | })) 41 | defer ts.Close() 42 | 43 | client := NewOdpsRestClient(MockAccount{}, ts.URL) 44 | var resp TestResponse 45 | 46 | err := client.GetWithModel("test", url.Values{}, nil, &resp) 47 | assert.NoError(t, err) 48 | assert.Equal(t, "Hello", resp.Message) 49 | } 50 | -------------------------------------------------------------------------------- /arrow/internal/cpu/cpu_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu_test 6 | 7 | import ( 8 | "runtime" 9 | "testing" 10 | 11 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/internal/cpu" 12 | ) 13 | 14 | func TestAMD64minimalFeatures(t *testing.T) { 15 | if runtime.GOARCH == "amd64" { 16 | if !cpu.X86.HasSSE2 { 17 | t.Fatalf("HasSSE2 expected true, got false") 18 | } 19 | } 20 | } 21 | 22 | func TestAVX2hasAVX(t *testing.T) { 23 | if runtime.GOARCH == "amd64" { 24 | if cpu.X86.HasAVX2 && !cpu.X86.HasAVX { 25 | t.Fatalf("HasAVX expected true, got false") 26 | } 27 | } 28 | } 29 | 30 | func TestPPC64minimalFeatures(t *testing.T) { 31 | if runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" { 32 | if !cpu.PPC64.IsPOWER8 { 33 | t.Fatalf("IsPOWER8 expected true, got false") 34 | } 35 | if !cpu.PPC64.HasVMX { 36 | t.Fatalf("HasVMX expected true, got false") 37 | } 38 | if !cpu.PPC64.HasDFP { 39 | t.Fatalf("HasDFP expected true, got false") 40 | } 41 | if !cpu.PPC64.HasVSX { 42 | t.Fatalf("HasVSX expected true, got false") 43 | } 44 | if !cpu.PPC64.HasISEL { 45 | t.Fatalf("HasISEL expected true, got false") 46 | } 47 | if !cpu.PPC64.HasVCRYPTO { 48 | t.Fatalf("HasVCRYPTO expected true, got false") 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /arrow/memory/memory_avx2_amd64.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !noasm 18 | // +build !noasm 19 | 20 | package memory 21 | 22 | import "unsafe" 23 | 24 | //go:noescape 25 | func _memset_avx2(buf unsafe.Pointer, len, c uintptr) 26 | 27 | func memory_memset_avx2(buf []byte, c byte) { 28 | if len(buf) == 0 { 29 | return 30 | } 31 | 32 | var ( 33 | p1 = unsafe.Pointer(&buf[0]) 34 | p2 = uintptr(len(buf)) 35 | p3 = uintptr(c) 36 | ) 37 | if len(buf) > 2000 || isMultipleOfPowerOf2(len(buf), 256) { 38 | _memset_avx2(p1, p2, p3) 39 | } else { 40 | _memset_sse4(p1, p2, p3) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /odps/data/binary.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package data 18 | 19 | import ( 20 | "fmt" 21 | 22 | "github.com/pkg/errors" 23 | 24 | "github.com/aliyun/aliyun-odps-go-sdk/odps/datatype" 25 | ) 26 | 27 | type Binary []byte 28 | 29 | func (b Binary) Type() datatype.DataType { 30 | return datatype.BinaryType 31 | } 32 | 33 | func (b Binary) String() string { 34 | return fmt.Sprintf("unhex('%X')", []byte(b)) 35 | } 36 | 37 | func (b Binary) Sql() string { 38 | return b.String() 39 | } 40 | 41 | func (b *Binary) Scan(value interface{}) error { 42 | return errors.WithStack(tryConvertType(value, b)) 43 | } 44 | -------------------------------------------------------------------------------- /examples/sdk/partition/get_partition_ext/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "./config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | 24 | project := odpsIns.Project(conf.ProjectName) 25 | tables := project.Tables() 26 | table := tables.Get("all_types_demo") 27 | 28 | p, err := table.GetPartition("p1=20/p2=hangzhou") 29 | if err != nil { 30 | log.Fatalf("%+v", err) 31 | } 32 | 33 | // Get the basic partition information 34 | fmt.Printf( 35 | "value=%s, createTime=%s, lastDDLTime=%s, lastModifiedTime=%s, size=%d\n", 36 | p.Value(), p.CreatedTime(), p.LastDDLTime(), p.LastModifiedTime(), p.Size(), 37 | ) 38 | 39 | // Get the extended partition information 40 | err = p.LoadExtended() 41 | if err != nil { 42 | log.Fatalf("%+v", err) 43 | } 44 | 45 | fmt.Printf( 46 | "isArchived=%t, lifeCycle=%d, physicalSize=%d", 47 | p.IsArchivedEx(), p.LifeCycleEx(), p.PhysicalSizeEx(), 48 | ) 49 | } 50 | -------------------------------------------------------------------------------- /arrow/math/int64_avx2_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_simd_amd64.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | import ( 25 | "unsafe" 26 | 27 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 28 | ) 29 | 30 | //go:noescape 31 | func _sum_int64_avx2(buf unsafe.Pointer, len uintptr, res unsafe.Pointer) 32 | 33 | func sum_int64_avx2(a *array.Int64) int64 { 34 | buf := a.Int64Values() 35 | var ( 36 | p1 = unsafe.Pointer(&buf[0]) 37 | p2 = uintptr(len(buf)) 38 | res int64 39 | ) 40 | _sum_int64_avx2(p1, p2, unsafe.Pointer(&res)) 41 | return res 42 | } 43 | -------------------------------------------------------------------------------- /arrow/math/int64_sse4_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_simd_amd64.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | import ( 25 | "unsafe" 26 | 27 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 28 | ) 29 | 30 | //go:noescape 31 | func _sum_int64_sse4(buf unsafe.Pointer, len uintptr, res unsafe.Pointer) 32 | 33 | func sum_int64_sse4(a *array.Int64) int64 { 34 | buf := a.Int64Values() 35 | var ( 36 | p1 = unsafe.Pointer(&buf[0]) 37 | p2 = uintptr(len(buf)) 38 | res int64 39 | ) 40 | _sum_int64_sse4(p1, p2, unsafe.Pointer(&res)) 41 | return res 42 | } 43 | -------------------------------------------------------------------------------- /arrow/math/type_simd_amd64.go.tmpl: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // +build !noasm 18 | 19 | package math 20 | 21 | import ( 22 | "unsafe" 23 | 24 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 25 | ) 26 | 27 | {{$name := printf "%s_%s" .In.Type .D.arch}} 28 | {{with .In}} 29 | //go:noescape 30 | func _sum_{{$name}}(buf unsafe.Pointer, len uintptr, res unsafe.Pointer) 31 | 32 | func sum_{{$name}}(a *array.{{.Name}}) {{.Type}} { 33 | buf := a.{{.Name}}Values() 34 | var ( 35 | p1 = unsafe.Pointer(&buf[0]) 36 | p2 = uintptr(len(buf)) 37 | res {{.Type}} 38 | ) 39 | _sum_{{$name}}(p1, p2, unsafe.Pointer(&res)) 40 | return res 41 | } 42 | {{end}} -------------------------------------------------------------------------------- /arrow/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | digest = "1:56c130d885a4aacae1dd9c7b71cfe39912c7ebc1ff7d2b46083c8812996dc43b" 6 | name = "github.com/davecgh/go-spew" 7 | packages = ["spew"] 8 | pruneopts = "" 9 | revision = "346938d642f2ec3594ed81d874461961cd0faa76" 10 | version = "v1.1.0" 11 | 12 | [[projects]] 13 | digest = "1:1d7e1867c49a6dd9856598ef7c3123604ea3daabf5b83f303ff457bcbc410b1d" 14 | name = "github.com/pkg/errors" 15 | packages = ["."] 16 | pruneopts = "" 17 | revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4" 18 | version = "v0.8.1" 19 | 20 | [[projects]] 21 | digest = "1:256484dbbcd271f9ecebc6795b2df8cad4c458dd0f5fd82a8c2fa0c29f233411" 22 | name = "github.com/pmezard/go-difflib" 23 | packages = ["difflib"] 24 | pruneopts = "" 25 | revision = "792786c7400a136282c1664665ae0a8db921c6c2" 26 | version = "v1.0.0" 27 | 28 | [[projects]] 29 | digest = "1:2d0dc026c4aef5e2f3a0e06a4dabe268b840d8f63190cf6894e02134a03f52c5" 30 | name = "github.com/stretchr/testify" 31 | packages = ["assert"] 32 | pruneopts = "" 33 | revision = "b91bfb9ebec76498946beb6af7c0230c7cc7ba6c" 34 | version = "v1.2.0" 35 | 36 | [solve-meta] 37 | analyzer-name = "dep" 38 | analyzer-version = 1 39 | input-imports = [ 40 | "github.com/pkg/errors", 41 | "github.com/stretchr/testify/assert", 42 | ] 43 | solver-name = "gps-cdcl" 44 | solver-version = 1 45 | -------------------------------------------------------------------------------- /arrow/datatype_null_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package arrow_test 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/aliyun/aliyun-odps-go-sdk/arrow" 23 | ) 24 | 25 | func TestNullType(t *testing.T) { 26 | var nt *arrow.NullType 27 | if got, want := nt.ID(), arrow.NULL; got != want { 28 | t.Fatalf("invalid null type id. got=%v, want=%v", got, want) 29 | } 30 | 31 | if got, want := nt.Name(), "null"; got != want { 32 | t.Fatalf("invalid null type name. got=%q, want=%q", got, want) 33 | } 34 | 35 | if got, want := nt.String(), "null"; got != want { 36 | t.Fatalf("invalid null type stringer. got=%q, want=%q", got, want) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /arrow/math/uint64_avx2_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_simd_amd64.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | import ( 25 | "unsafe" 26 | 27 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 28 | ) 29 | 30 | //go:noescape 31 | func _sum_uint64_avx2(buf unsafe.Pointer, len uintptr, res unsafe.Pointer) 32 | 33 | func sum_uint64_avx2(a *array.Uint64) uint64 { 34 | buf := a.Uint64Values() 35 | var ( 36 | p1 = unsafe.Pointer(&buf[0]) 37 | p2 = uintptr(len(buf)) 38 | res uint64 39 | ) 40 | _sum_uint64_avx2(p1, p2, unsafe.Pointer(&res)) 41 | return res 42 | } 43 | -------------------------------------------------------------------------------- /arrow/math/uint64_sse4_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_simd_amd64.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | import ( 25 | "unsafe" 26 | 27 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 28 | ) 29 | 30 | //go:noescape 31 | func _sum_uint64_sse4(buf unsafe.Pointer, len uintptr, res unsafe.Pointer) 32 | 33 | func sum_uint64_sse4(a *array.Uint64) uint64 { 34 | buf := a.Uint64Values() 35 | var ( 36 | p1 = unsafe.Pointer(&buf[0]) 37 | p2 = uintptr(len(buf)) 38 | res uint64 39 | ) 40 | _sum_uint64_sse4(p1, p2, unsafe.Pointer(&res)) 41 | return res 42 | } 43 | -------------------------------------------------------------------------------- /arrow/math/float64_avx2_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_simd_amd64.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | import ( 25 | "unsafe" 26 | 27 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 28 | ) 29 | 30 | //go:noescape 31 | func _sum_float64_avx2(buf unsafe.Pointer, len uintptr, res unsafe.Pointer) 32 | 33 | func sum_float64_avx2(a *array.Float64) float64 { 34 | buf := a.Float64Values() 35 | var ( 36 | p1 = unsafe.Pointer(&buf[0]) 37 | p2 = uintptr(len(buf)) 38 | res float64 39 | ) 40 | _sum_float64_avx2(p1, p2, unsafe.Pointer(&res)) 41 | return res 42 | } 43 | -------------------------------------------------------------------------------- /arrow/math/float64_sse4_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type_simd_amd64.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | //go:build !noasm 20 | // +build !noasm 21 | 22 | package math 23 | 24 | import ( 25 | "unsafe" 26 | 27 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 28 | ) 29 | 30 | //go:noescape 31 | func _sum_float64_sse4(buf unsafe.Pointer, len uintptr, res unsafe.Pointer) 32 | 33 | func sum_float64_sse4(a *array.Float64) float64 { 34 | buf := a.Float64Values() 35 | var ( 36 | p1 = unsafe.Pointer(&buf[0]) 37 | p2 = uintptr(len(buf)) 38 | res float64 39 | ) 40 | _sum_float64_sse4(p1, p2, unsafe.Pointer(&res)) 41 | return res 42 | } 43 | -------------------------------------------------------------------------------- /arrow/math/math_amd64.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | //go:build !noasm 18 | // +build !noasm 19 | 20 | package math 21 | 22 | import ( 23 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/internal/cpu" 24 | ) 25 | 26 | func init() { 27 | if cpu.X86.HasAVX2 { 28 | initAVX2() 29 | } else if cpu.X86.HasSSE42 { 30 | initSSE4() 31 | } else { 32 | initGo() 33 | } 34 | } 35 | 36 | func initAVX2() { 37 | initFloat64AVX2() 38 | initInt64AVX2() 39 | initUint64AVX2() 40 | } 41 | 42 | func initSSE4() { 43 | initFloat64SSE4() 44 | initInt64SSE4() 45 | initUint64SSE4() 46 | } 47 | 48 | func initGo() { 49 | initFloat64Go() 50 | initInt64Go() 51 | initUint64Go() 52 | } 53 | -------------------------------------------------------------------------------- /arrow/internal/testing/tools/bits_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package tools_test 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | 23 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/internal/testing/tools" 24 | "github.com/stretchr/testify/assert" 25 | ) 26 | 27 | func TestIntsToBitsLSB(t *testing.T) { 28 | tests := []struct { 29 | in int32 30 | exp byte 31 | }{ 32 | {0x11001010, 0x53}, 33 | {0x00001111, 0xf0}, 34 | {0x11110000, 0x0f}, 35 | } 36 | for _, test := range tests { 37 | t.Run(fmt.Sprintf("%08x", test.in), func(t *testing.T) { 38 | got := tools.IntsToBitsLSB(test.in) 39 | assert.Equal(t, []byte{test.exp}, got) 40 | }) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /odps/data/record.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package data 18 | 19 | import "strings" 20 | 21 | type Record []Data 22 | 23 | func NewRecord(columnNums int) Record { 24 | return make([]Data, columnNums) 25 | } 26 | 27 | func (r *Record) Len() int { 28 | return len(*r) 29 | } 30 | 31 | func (r *Record) Get(i int) Data { 32 | return (*r)[i] 33 | } 34 | 35 | func (r *Record) String() string { 36 | var sb strings.Builder 37 | sb.WriteString("[") 38 | 39 | n := len(*r) - 1 40 | for i, f := range *r { 41 | sb.WriteString(f.String()) 42 | 43 | if i < n { 44 | sb.WriteString(", ") 45 | } 46 | } 47 | 48 | sb.WriteString("]") 49 | 50 | return sb.String() 51 | } 52 | -------------------------------------------------------------------------------- /arrow/math/int64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | package math 20 | 21 | import ( 22 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 23 | ) 24 | 25 | type Int64Funcs struct { 26 | sum func(a *array.Int64) int64 27 | } 28 | 29 | var ( 30 | Int64 Int64Funcs 31 | ) 32 | 33 | // Sum returns the summation of all elements in a. 34 | func (f Int64Funcs) Sum(a *array.Int64) int64 { 35 | if a.Len() == 0 { 36 | return int64(0) 37 | } 38 | return f.sum(a) 39 | } 40 | 41 | func sum_int64_go(a *array.Int64) int64 { 42 | acc := int64(0) 43 | for _, v := range a.Int64Values() { 44 | acc += v 45 | } 46 | return acc 47 | } 48 | -------------------------------------------------------------------------------- /odps/account/bearer_token_account.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package account 18 | 19 | import ( 20 | "net/http" 21 | 22 | "github.com/aliyun/aliyun-odps-go-sdk/odps/common" 23 | ) 24 | 25 | type BearerTokenAccount struct { 26 | token string 27 | } 28 | 29 | func NewBearerTokenAccount(token string) *BearerTokenAccount { 30 | return &BearerTokenAccount{ 31 | token: token, 32 | } 33 | } 34 | 35 | func (account *BearerTokenAccount) GetType() Provider { 36 | return BearToken 37 | } 38 | 39 | func (account *BearerTokenAccount) SignRequest(req *http.Request, _ string) error { 40 | req.Header.Set(common.HttpHeaderODPSBearerToken, account.token) 41 | 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /arrow/math/uint64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | package math 20 | 21 | import ( 22 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 23 | ) 24 | 25 | type Uint64Funcs struct { 26 | sum func(a *array.Uint64) uint64 27 | } 28 | 29 | var ( 30 | Uint64 Uint64Funcs 31 | ) 32 | 33 | // Sum returns the summation of all elements in a. 34 | func (f Uint64Funcs) Sum(a *array.Uint64) uint64 { 35 | if a.Len() == 0 { 36 | return uint64(0) 37 | } 38 | return f.sum(a) 39 | } 40 | 41 | func sum_uint64_go(a *array.Uint64) uint64 { 42 | acc := uint64(0) 43 | for _, v := range a.Uint64Values() { 44 | acc += v 45 | } 46 | return acc 47 | } 48 | -------------------------------------------------------------------------------- /examples/sdk/tunnel/upload_data_use_protoc_with_quota/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 10 | "github.com/aliyun/aliyun-odps-go-sdk/odps/data" 11 | "github.com/aliyun/aliyun-odps-go-sdk/odps/tunnel" 12 | ) 13 | 14 | func main() { 15 | conf, err := odps.NewConfigFromIni(os.Args[1]) 16 | if err != nil { 17 | log.Fatalf("%+v", err) 18 | } 19 | 20 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 21 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | tunnelIns := tunnel.NewTunnel(odpsIns) 24 | tunnelIns.SetQuotaName(conf.TunnelQuotaName) 25 | 26 | session, err := tunnelIns.CreateUploadSession( 27 | conf.ProjectName, 28 | "mf_test", 29 | ) 30 | if err != nil { 31 | log.Fatalf("%+v", err) 32 | } 33 | fmt.Println("tunnel endpoint: " + tunnelIns.GetEndpoint()) 34 | 35 | recordWriter, err := session.OpenRecordWriter(0) 36 | str := data.String("maxcompute") 37 | 38 | record := []data.Data{ 39 | data.Int(100), 40 | str, 41 | } 42 | 43 | for i := 0; i < 1; i++ { 44 | err = recordWriter.Write(record) 45 | if err != nil { 46 | log.Fatalf("%+v", err) 47 | } 48 | } 49 | 50 | err = recordWriter.Close() 51 | if err != nil { 52 | log.Fatalf("%+v", err) 53 | } 54 | 55 | err = session.Commit([]int{0}) 56 | if err != nil { 57 | log.Fatalf("%+v", err) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /arrow/math/float64.go: -------------------------------------------------------------------------------- 1 | // Code generated by type.go.tmpl. DO NOT EDIT. 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one 4 | // or more contributor license agreements. See the NOTICE file 5 | // distributed with this work for additional information 6 | // regarding copyright ownership. The ASF licenses this file 7 | // to you under the Apache License, Version 2.0 (the 8 | // "License"); you may not use this file except in compliance 9 | // with the License. You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | package math 20 | 21 | import ( 22 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 23 | ) 24 | 25 | type Float64Funcs struct { 26 | sum func(a *array.Float64) float64 27 | } 28 | 29 | var ( 30 | Float64 Float64Funcs 31 | ) 32 | 33 | // Sum returns the summation of all elements in a. 34 | func (f Float64Funcs) Sum(a *array.Float64) float64 { 35 | if a.Len() == 0 { 36 | return float64(0) 37 | } 38 | return f.sum(a) 39 | } 40 | 41 | func sum_float64_go(a *array.Float64) float64 { 42 | acc := float64(0) 43 | for _, v := range a.Float64Values() { 44 | acc += v 45 | } 46 | return acc 47 | } 48 | -------------------------------------------------------------------------------- /examples/sdk/exec_sql/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/options" 9 | ) 10 | 11 | func main() { 12 | // Specify the ini file path 13 | configPath := "config.ini" 14 | conf, err := odps.NewConfigFromIni(configPath) 15 | if err != nil { 16 | log.Fatalf("%+v", err) 17 | } 18 | 19 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 20 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 21 | // Set the Default Maxcompute project used By Odps instance 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | odpsIns.SetCurrentSchemaName("default") 24 | 25 | ins1, err := odpsIns.ExecSQl("select 1;") 26 | if err != nil { 27 | log.Fatalf("%+v", err) 28 | } 29 | err = ins1.WaitForSuccess() 30 | if err != nil { 31 | log.Fatalf("%+v", err) 32 | } 33 | println(ins1.Id()) 34 | 35 | instanceOption := options.NewCreateInstanceOptions() 36 | instanceOption.UniqueIdentifyID = "123456" 37 | 38 | option := options.NewSQLTaskOptions() 39 | option.InstanceOption = instanceOption 40 | 41 | ins2, err := odpsIns.ExecSQlWithOption("select 1;", option) 42 | if err != nil { 43 | log.Fatalf("%+v", err) 44 | } 45 | println(ins2.Id()) 46 | 47 | ins3, err := odpsIns.ExecSQlWithOption("select 2;", option) 48 | if err != nil { 49 | log.Fatalf("%+v", err) 50 | } 51 | println(ins3.Id()) 52 | 53 | println(ins2.Id() == ins3.Id()) 54 | } 55 | -------------------------------------------------------------------------------- /arrow/math/type.go.tmpl: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package math 18 | 19 | import ( 20 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 21 | ) 22 | 23 | {{$def := .D}} 24 | {{with .In}} 25 | type {{.Name}}Funcs struct { 26 | sum func(a *array.{{.Name}}) {{.Type}} 27 | } 28 | 29 | var ( 30 | {{.Name}} {{.Name}}Funcs 31 | ) 32 | 33 | // Sum returns the summation of all elements in a. 34 | func (f {{.Name}}Funcs) Sum(a *array.{{.Name}}) {{.Type}} { 35 | if a.Len() == 0 { 36 | return {{.Type}}(0) 37 | } 38 | return f.sum(a) 39 | } 40 | 41 | func sum_{{.Type}}_go(a *array.{{.Name}}) {{.Type}} { 42 | acc := {{.Type}}(0) 43 | for _, v := range a.{{.Name}}Values() { 44 | acc += v 45 | } 46 | return acc 47 | } 48 | {{end}} -------------------------------------------------------------------------------- /arrow/scalar/compare.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package scalar 18 | 19 | import "github.com/aliyun/aliyun-odps-go-sdk/arrow" 20 | 21 | //TODO(zeroshade): approxequals 22 | // tracked in https://issues.apache.org/jira/browse/ARROW-13980 23 | 24 | // Equals returns true if two scalars are equal, which means they have the same 25 | // datatype, validity and value. 26 | func Equals(left, right Scalar) bool { 27 | if left == right { 28 | return true 29 | } 30 | 31 | if !arrow.TypeEqual(left.DataType(), right.DataType()) { 32 | return false 33 | } 34 | 35 | if left.IsValid() != right.IsValid() { 36 | return false 37 | } 38 | 39 | if !left.IsValid() { 40 | return true 41 | } 42 | 43 | return left.equals(right) 44 | } 45 | -------------------------------------------------------------------------------- /arrow/internal/flatbuf/UnionMode.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 18 | 19 | package flatbuf 20 | 21 | import "strconv" 22 | 23 | type UnionMode int16 24 | 25 | const ( 26 | UnionModeSparse UnionMode = 0 27 | UnionModeDense UnionMode = 1 28 | ) 29 | 30 | var EnumNamesUnionMode = map[UnionMode]string{ 31 | UnionModeSparse: "Sparse", 32 | UnionModeDense: "Dense", 33 | } 34 | 35 | var EnumValuesUnionMode = map[string]UnionMode{ 36 | "Sparse": UnionModeSparse, 37 | "Dense": UnionModeDense, 38 | } 39 | 40 | func (v UnionMode) String() string { 41 | if s, ok := EnumNamesUnionMode[v]; ok { 42 | return s 43 | } 44 | return "UnionMode(" + strconv.FormatInt(int64(v), 10) + ")" 45 | } 46 | -------------------------------------------------------------------------------- /examples/sdk/aliyun_credential/use_sts_token/use_sts_token_by_custom_provider/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aliyun/credentials-go/credentials" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 10 | ) 11 | 12 | type CustomCredentialProvider struct{} 13 | 14 | func (cp *CustomCredentialProvider) GetType() (*string, error) { 15 | s := "CustomProvider" 16 | return &s, nil 17 | } 18 | 19 | func (cp *CustomCredentialProvider) GetCredential() (*credentials.CredentialModel, error) { 20 | accessKeyId := "" 21 | accessKeySecurity := "" 22 | accessKeyToken := "" 23 | 24 | return &credentials.CredentialModel{ 25 | AccessKeyId: &accessKeyId, 26 | AccessKeySecret: &accessKeyToken, 27 | SecurityToken: &accessKeySecurity, 28 | }, nil 29 | } 30 | 31 | func main() { 32 | provider := &CustomCredentialProvider{} 33 | 34 | stsAccount := account.NewStsAccountWithProvider(provider) 35 | 36 | // Get the endpoint of a specific region from https://www.alibabacloud.com/help/en/maxcompute/user-guide/endpoints 37 | // 获取具体的endpoint请参考 https://help.aliyun.com/zh/maxcompute/user-guide/endpoints 38 | // The following an example endpoint of cn-hangzhou 39 | endpoint := "http://service.cn-hangzhou.maxcompute.aliyun.com/api" 40 | 41 | // The Default Maxcompute project used by Odps instance 42 | defaultProject := "" 43 | 44 | odpsIns := odps.NewOdps(stsAccount, endpoint) 45 | odpsIns.SetDefaultProjectName(defaultProject) 46 | 47 | fmt.Printf("odps:%#v\n", odpsIns) 48 | } 49 | -------------------------------------------------------------------------------- /arrow/internal/testing/tools/bits.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package tools 18 | 19 | import "math/bits" 20 | 21 | // IntsToBitsLSB encodes ints as LSB 0 bit numbering per https://en.wikipedia.org/wiki/Bit_numbering#LSB_0_bit_numbering 22 | // The low bit of each nibble is tested, therefore integers should be written as 8-digit 23 | // hex numbers consisting of 1s or 0s. 24 | // 25 | // IntsToBitsLSB(0x11001010) -> 0x35 26 | func IntsToBitsLSB(v ...int32) []byte { 27 | res := make([]byte, 0, len(v)) 28 | for _, b := range v { 29 | c := uint8(0) 30 | for i := uint(0); i < 8; i++ { 31 | if b&1 == 1 { 32 | c |= 1 << i 33 | } 34 | b >>= 4 35 | } 36 | c = bits.Reverse8(c) 37 | res = append(res, c) 38 | } 39 | return res 40 | } 41 | -------------------------------------------------------------------------------- /arrow/memory/internal/cgoalloc/allocator.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef uintptr_t ArrowMemoryPool; 28 | 29 | ArrowMemoryPool arrow_create_memory_pool(bool enable_logging); 30 | int arrow_pool_allocate(ArrowMemoryPool pool, int64_t size, uint8_t** out); 31 | int arrow_pool_reallocate(ArrowMemoryPool pool, int64_t old_size, int64_t new_size, uint8_t** ptr); 32 | void arrow_pool_free(ArrowMemoryPool pool, uint8_t* buffer, int64_t size); 33 | int64_t arrow_pool_bytes_allocated(ArrowMemoryPool pool); 34 | void arrow_release_pool(ArrowMemoryPool pool); 35 | 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /odps/security/auth_query_instance.go: -------------------------------------------------------------------------------- 1 | package security 2 | 3 | import ( 4 | "encoding/xml" 5 | "time" 6 | 7 | "github.com/pkg/errors" 8 | ) 9 | 10 | const ( 11 | TerminatedStatus = "Terminated" 12 | FailedStatus = "Failed" 13 | RunningStatus = "Running" 14 | ) 15 | 16 | type AuthQueryInstance struct { 17 | result string 18 | sm *Manager 19 | authId string 20 | isSync bool 21 | } 22 | 23 | func newAuthQueryInstance(sm *Manager, authId string) *AuthQueryInstance { 24 | return &AuthQueryInstance{ 25 | sm: sm, 26 | authId: authId, 27 | } 28 | } 29 | 30 | func newAuthQueryInstanceWithResult(result string) *AuthQueryInstance { 31 | return &AuthQueryInstance{ 32 | result: result, 33 | isSync: true, 34 | } 35 | } 36 | 37 | func (ai *AuthQueryInstance) WaitForSuccess() (string, error) { 38 | if ai.isSync { 39 | return ai.result, nil 40 | } 41 | 42 | rb := ai.sm.rb() 43 | authResource := rb.AuthorizationId(ai.authId) 44 | client := ai.sm.restClient 45 | 46 | type ResModel struct { 47 | XMLName xml.Name `xml:"AuthorizationQuery"` 48 | Result string 49 | Status string 50 | } 51 | var resModel ResModel 52 | 53 | for { 54 | err := client.GetWithModel(authResource, nil, nil, &resModel) 55 | if err != nil { 56 | return "", err 57 | } 58 | 59 | if resModel.Status == TerminatedStatus { 60 | return resModel.Result, nil 61 | } 62 | 63 | if resModel.Status == FailedStatus { 64 | return "", errors.Errorf("Authorization query failed: %s", resModel.Result) 65 | } 66 | 67 | time.Sleep(time.Second * 1) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /examples/sdk/aliyun_credential/use_sts_token/use_sts_token_from_ecs_ram_role/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/aliyun/credentials-go/credentials" 8 | 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 10 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 11 | ) 12 | 13 | func main() { 14 | config := new(credentials.Config). 15 | // Which type of credential you want 16 | SetType("ecs_ram_role"). 17 | // `roleName` is optional. It will be retrieved automatically if not set. It is highly recommended to set it up to reduce requests 18 | SetRoleName("RoleName"). 19 | // `DisableIMDSv1` is optional and is recommended to be turned on. It can be replaced by setting environment variable: ALIBABA_CLOUD_IMDSV1_DISABLED 20 | SetDisableIMDSv1(true) 21 | 22 | credential, err := credentials.NewCredential(config) 23 | if err != nil { 24 | log.Fatalf("%+v", err) 25 | } 26 | 27 | stsAccount := account.NewStsAccountWithCredential(credential) 28 | 29 | // Get the endpoint of a specific region from https://www.alibabacloud.com/help/en/maxcompute/user-guide/endpoints 30 | // 获取具体的endpoint请参考 https://help.aliyun.com/zh/maxcompute/user-guide/endpoints 31 | // The following an example endpoint of cn-hangzhou 32 | endpoint := "http://service.cn-hangzhou.maxcompute.aliyun.com/api" 33 | 34 | // The Default Maxcompute project used by Odps instance 35 | defaultProject := "" 36 | 37 | odpsIns := odps.NewOdps(stsAccount, endpoint) 38 | odpsIns.SetDefaultProjectName(defaultProject) 39 | 40 | fmt.Printf("odps:%#v\n", odpsIns) 41 | } 42 | -------------------------------------------------------------------------------- /arrow/internal/flatbuf/DateUnit.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 18 | 19 | package flatbuf 20 | 21 | import "strconv" 22 | 23 | type DateUnit int16 24 | 25 | const ( 26 | DateUnitDAY DateUnit = 0 27 | DateUnitMILLISECOND DateUnit = 1 28 | ) 29 | 30 | var EnumNamesDateUnit = map[DateUnit]string{ 31 | DateUnitDAY: "DAY", 32 | DateUnitMILLISECOND: "MILLISECOND", 33 | } 34 | 35 | var EnumValuesDateUnit = map[string]DateUnit{ 36 | "DAY": DateUnitDAY, 37 | "MILLISECOND": DateUnitMILLISECOND, 38 | } 39 | 40 | func (v DateUnit) String() string { 41 | if s, ok := EnumNamesDateUnit[v]; ok { 42 | return s 43 | } 44 | return "DateUnit(" + strconv.FormatInt(int64(v), 10) + ")" 45 | } 46 | -------------------------------------------------------------------------------- /examples/sdk/select_data/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "log" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 10 | ) 11 | 12 | func main() { 13 | // Specify the ini file path 14 | configPath := "./config.ini" 15 | conf, err := odps.NewConfigFromIni(configPath) 16 | if err != nil { 17 | log.Fatalf("%+v", err) 18 | } 19 | 20 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 21 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 22 | // Set the Default Maxcompute project used By Odps instance 23 | odpsIns.SetDefaultProjectName(conf.ProjectName) 24 | 25 | sql := "select * from all_types_demo where p1>0 or p2 > '';" 26 | 27 | // The flags used by sql engine, such as odps.sql.skewjoin 28 | var hints map[string]string = nil 29 | 30 | // Create a SqlTask 31 | sqlTask := odps.NewSqlTask("select", sql, hints) 32 | 33 | // Run the sql with the quota associated with a project 34 | project := odpsIns.DefaultProjectName() 35 | ins, err := sqlTask.Run(odpsIns, project) 36 | if err != nil { 37 | log.Fatalf("%+v", err) 38 | } 39 | 40 | err = ins.WaitForSuccess() 41 | if err != nil { 42 | log.Fatalf("%+v", err) 43 | } 44 | 45 | csvReader, err := sqlTask.GetSelectResultAsCsv(ins, true) 46 | if err != nil { 47 | log.Fatalf("%+v", err) 48 | } 49 | 50 | for { 51 | record, err := csvReader.Read() 52 | if err == io.EOF { 53 | break 54 | } 55 | if err != nil { 56 | log.Fatalf("%+v", err) 57 | } 58 | fmt.Printf("%v\n", record) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /arrow/ipc/record_batch_writer.go: -------------------------------------------------------------------------------- 1 | package ipc 2 | 3 | import ( 4 | "github.com/aliyun/aliyun-odps-go-sdk/arrow" 5 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/array" 6 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/internal/flatbuf" 7 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/memory" 8 | "golang.org/x/xerrors" 9 | "io" 10 | ) 11 | 12 | type RecordBatchWriter struct { 13 | w io.Writer 14 | 15 | mem memory.Allocator 16 | pw PayloadWriter 17 | 18 | schema *arrow.Schema 19 | codec flatbuf.CompressionType 20 | compressNP int 21 | } 22 | 23 | func NewRecordBatchWriter(w io.Writer, opts ...Option) *RecordBatchWriter { 24 | cfg := newConfig(opts...) 25 | return &RecordBatchWriter{ 26 | w: w, 27 | mem: cfg.alloc, 28 | pw: &swriter{w: w}, 29 | schema: cfg.schema, 30 | codec: cfg.codec, 31 | compressNP: cfg.compressNP, 32 | } 33 | } 34 | 35 | func (w *RecordBatchWriter) Write(rec array.Record) error { 36 | schema := rec.Schema() 37 | if schema == nil || !schema.Equal(w.schema) { 38 | return errInconsistentSchema 39 | } 40 | 41 | const allow64b = true 42 | var ( 43 | data = Payload{msg: MessageRecordBatch} 44 | enc = newRecordEncoder(w.mem, 0, kMaxNestingDepth, allow64b, w.codec, w.compressNP) 45 | ) 46 | defer data.Release() 47 | 48 | if err := enc.Encode(&data, rec); err != nil { 49 | return xerrors.Errorf("arrow/ipc: could not encode record to payload: %w", err) 50 | } 51 | 52 | return w.pw.WritePayload(data) 53 | } 54 | 55 | func (w *RecordBatchWriter) Close() error { 56 | w.pw = nil 57 | return nil 58 | } 59 | -------------------------------------------------------------------------------- /arrow/datatype_numeric.gen.go.tmpl: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package arrow 18 | 19 | {{range .In}} 20 | type {{.Name}}Type struct {} 21 | 22 | func (t *{{.Name}}Type) ID() Type { return {{.Name|upper}} } 23 | func (t *{{.Name}}Type) Name() string { return "{{.Name|lower}}" } 24 | func (t *{{.Name}}Type) String() string { return "{{.Name|lower}}" } 25 | func (t *{{.Name}}Type) BitWidth() int { return {{.Size}} } 26 | func (t *{{.Name}}Type) Fingerprint() string { return typeFingerprint(t) } 27 | 28 | {{end}} 29 | 30 | var ( 31 | PrimitiveTypes = struct { 32 | {{range .In}} 33 | {{.Name}} DataType 34 | {{- end}} 35 | }{ 36 | {{range .In}} 37 | {{.Name}}: &{{.Name}}Type{}, 38 | {{- end}} 39 | } 40 | ) 41 | -------------------------------------------------------------------------------- /arrow/internal/flight_integration/cmd/arrow-flight-integration-server/main.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package main 18 | 19 | import ( 20 | "flag" 21 | "fmt" 22 | "net" 23 | "os" 24 | "syscall" 25 | 26 | "github.com/aliyun/aliyun-odps-go-sdk/arrow/internal/flight_integration" 27 | ) 28 | 29 | var ( 30 | port = flag.Int("port", 31337, "Server port to listen on") 31 | scenario = flag.String("scenario", "", "Integration test scenario to run") 32 | ) 33 | 34 | func main() { 35 | flag.Parse() 36 | 37 | s := flight_integration.GetScenario(*scenario) 38 | srv := s.MakeServer(*port) 39 | srv.SetShutdownOnSignals(syscall.SIGTERM, os.Interrupt) 40 | _, p, _ := net.SplitHostPort(srv.Addr().String()) 41 | fmt.Printf("Server listening on localhost:%s\n", p) 42 | srv.Serve() 43 | } 44 | -------------------------------------------------------------------------------- /.github/workflows/ci-go1.15.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a golang project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go 3 | 4 | name: CI-go1.15 5 | 6 | on: 7 | workflow_dispatch: # 支持手动触发 8 | 9 | jobs: 10 | 11 | build: 12 | runs-on: ubuntu-latest 13 | permissions: 14 | id-token: write # 获取 oidc token 的权限 15 | steps: 16 | - name: get credentials 17 | id: get-credentials 18 | uses: aliyun/configure-aliyun-credentials-action@v1.0.3 19 | with: 20 | role-to-assume: '${{ secrets.ROLE_ARN }}' 21 | oidc-provider-arn: '${{ secrets.OIDC_ARN }}' 22 | audience: 'actions.github.com' # default value 23 | 24 | - name: Set up environment 25 | run: | 26 | echo "ALIBABA_CLOUD_ACCESS_KEY_ID=${{ steps.get-credentials.outputs.aliyun-access-key-id }}" >> $GITHUB_ENV 27 | echo "ALIBABA_CLOUD_ACCESS_KEY_SECRET=${{ steps.get-credentials.outputs.aliyun-access-key-secret }}" >> $GITHUB_ENV 28 | echo "ALIBABA_CLOUD_SECURITY_TOKEN=${{ steps.get-credentials.outputs.aliyun-security-token }}" >> $GITHUB_ENV 29 | echo "odps_endpoint=${{ secrets.ENDPOINT }}" >> $GITHUB_ENV 30 | echo "TZ=Asia/Shanghai" >> $GITHUB_ENV 31 | 32 | - uses: actions/checkout@v4 33 | 34 | - name: Set up Go 35 | uses: actions/setup-go@v4 36 | with: 37 | go-version: '1.15' 38 | 39 | - name: Build 40 | run: go build -v ./... 41 | 42 | - name: Test (Expect Arrow Package) 43 | run: go test -v $(go list ./... | grep -v './arrow') 44 | -------------------------------------------------------------------------------- /odps/data/util.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package data 18 | 19 | import ( 20 | "reflect" 21 | 22 | "github.com/pkg/errors" 23 | ) 24 | 25 | func tryConvertType(src interface{}, dst interface{}) error { 26 | if src == nil { 27 | // TODO 这个地方要看一下, 要不要做: dst = nil 28 | return nil 29 | } 30 | 31 | srcT := reflect.TypeOf(src) 32 | srcV := reflect.ValueOf(src) 33 | 34 | dstT := reflect.TypeOf(dst) 35 | dstV := reflect.ValueOf(dst) 36 | 37 | if srcV.Kind() == reflect.Ptr { 38 | srcT = srcT.Elem() 39 | srcV = srcV.Elem() 40 | } 41 | 42 | if dstV.Kind() == reflect.Ptr { 43 | dstT = dstT.Elem() 44 | dstV = dstV.Elem() 45 | } 46 | 47 | if srcT.AssignableTo(dstT) { 48 | dstV.Set(srcV) 49 | return nil 50 | } 51 | 52 | return errors.Errorf("cannot convert %s to %s", srcT.Name(), dstT.Name()) 53 | } 54 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a golang project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go 3 | 4 | name: CI 5 | 6 | on: 7 | workflow_dispatch: # 支持手动触发 8 | push: 9 | branches: [ "master" ] 10 | 11 | jobs: 12 | 13 | build: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | id-token: write # 获取 oidc token 的权限 17 | steps: 18 | - name: get credentials 19 | id: get-credentials 20 | uses: aliyun/configure-aliyun-credentials-action@v1.0.3 21 | with: 22 | role-to-assume: '${{ secrets.ROLE_ARN }}' 23 | oidc-provider-arn: '${{ secrets.OIDC_ARN }}' 24 | audience: 'actions.github.com' # default value 25 | 26 | - name: Set up environment 27 | run: | 28 | echo "ALIBABA_CLOUD_ACCESS_KEY_ID=${{ steps.get-credentials.outputs.aliyun-access-key-id }}" >> $GITHUB_ENV 29 | echo "ALIBABA_CLOUD_ACCESS_KEY_SECRET=${{ steps.get-credentials.outputs.aliyun-access-key-secret }}" >> $GITHUB_ENV 30 | echo "ALIBABA_CLOUD_SECURITY_TOKEN=${{ steps.get-credentials.outputs.aliyun-security-token }}" >> $GITHUB_ENV 31 | echo "odps_endpoint=${{ secrets.ENDPOINT }}" >> $GITHUB_ENV 32 | echo "TZ=Asia/Shanghai" >> $GITHUB_ENV 33 | 34 | - uses: actions/checkout@v4 35 | 36 | - name: Set up Go 37 | uses: actions/setup-go@v4 38 | with: 39 | go-version: '1.21' 40 | 41 | - name: Build 42 | run: go build -v ./... 43 | 44 | - name: Test (Expect Arrow Package) 45 | run: go test -v $(go list ./... | grep -v './arrow') 46 | -------------------------------------------------------------------------------- /arrow/internal/flatbuf/Precision.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 18 | 19 | package flatbuf 20 | 21 | import "strconv" 22 | 23 | type Precision int16 24 | 25 | const ( 26 | PrecisionHALF Precision = 0 27 | PrecisionSINGLE Precision = 1 28 | PrecisionDOUBLE Precision = 2 29 | ) 30 | 31 | var EnumNamesPrecision = map[Precision]string{ 32 | PrecisionHALF: "HALF", 33 | PrecisionSINGLE: "SINGLE", 34 | PrecisionDOUBLE: "DOUBLE", 35 | } 36 | 37 | var EnumValuesPrecision = map[string]Precision{ 38 | "HALF": PrecisionHALF, 39 | "SINGLE": PrecisionSINGLE, 40 | "DOUBLE": PrecisionDOUBLE, 41 | } 42 | 43 | func (v Precision) String() string { 44 | if s, ok := EnumNamesPrecision[v]; ok { 45 | return s 46 | } 47 | return "Precision(" + strconv.FormatInt(int64(v), 10) + ")" 48 | } 49 | -------------------------------------------------------------------------------- /arrow/memory/go_allocator.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package memory 18 | 19 | type GoAllocator struct{} 20 | 21 | func NewGoAllocator() *GoAllocator { return &GoAllocator{} } 22 | 23 | func (a *GoAllocator) Allocate(size int) []byte { 24 | buf := make([]byte, size+alignment) // padding for 64-byte alignment 25 | addr := int(addressOf(buf)) 26 | next := roundUpToMultipleOf64(addr) 27 | if addr != next { 28 | shift := next - addr 29 | return buf[shift : size+shift : size+shift] 30 | } 31 | return buf[:size:size] 32 | } 33 | 34 | func (a *GoAllocator) Reallocate(size int, b []byte) []byte { 35 | if size == len(b) { 36 | return b 37 | } 38 | 39 | newBuf := a.Allocate(size) 40 | copy(newBuf, b) 41 | return newBuf 42 | } 43 | 44 | func (a *GoAllocator) Free(b []byte) {} 45 | 46 | var ( 47 | _ Allocator = (*GoAllocator)(nil) 48 | ) 49 | -------------------------------------------------------------------------------- /arrow/internal/flatbuf/CompressionType.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 18 | 19 | package flatbuf 20 | 21 | import "strconv" 22 | 23 | type CompressionType int8 24 | 25 | const ( 26 | CompressionTypeLZ4_FRAME CompressionType = 0 27 | CompressionTypeZSTD CompressionType = 1 28 | ) 29 | 30 | var EnumNamesCompressionType = map[CompressionType]string{ 31 | CompressionTypeLZ4_FRAME: "LZ4_FRAME", 32 | CompressionTypeZSTD: "ZSTD", 33 | } 34 | 35 | var EnumValuesCompressionType = map[string]CompressionType{ 36 | "LZ4_FRAME": CompressionTypeLZ4_FRAME, 37 | "ZSTD": CompressionTypeZSTD, 38 | } 39 | 40 | func (v CompressionType) String() string { 41 | if s, ok := EnumNamesCompressionType[v]; ok { 42 | return s 43 | } 44 | return "CompressionType(" + strconv.FormatInt(int64(v), 10) + ")" 45 | } 46 | -------------------------------------------------------------------------------- /arrow/float16/float16_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package float16 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestFloat16(t *testing.T) { 27 | cases := map[Num]float32{ 28 | {bits: 0x3c00}: 1, 29 | {bits: 0x4000}: 2, 30 | {bits: 0xc000}: -2, 31 | {bits: 0x0000}: 0, 32 | {bits: 0x5b8f}: 241.875, 33 | {bits: 0xdb8f}: -241.875, 34 | {bits: 0x48c8}: 9.5625, 35 | {bits: 0xc8c8}: -9.5625, 36 | } 37 | for k, v := range cases { 38 | f := k.Float32() 39 | assert.Equal(t, v, f, "float32 values should be the same") 40 | i := New(v) 41 | assert.Equal(t, k.bits, i.bits, "float16 values should be the same") 42 | assert.Equal(t, k.Uint16(), i.Uint16(), "float16 values should be the same") 43 | assert.Equal(t, k.String(), fmt.Sprintf("%v", v), "string representation differ") 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /arrow/internal/flatbuf/Bool.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 18 | 19 | package flatbuf 20 | 21 | import ( 22 | flatbuffers "github.com/google/flatbuffers/go" 23 | ) 24 | 25 | type Bool struct { 26 | _tab flatbuffers.Table 27 | } 28 | 29 | func GetRootAsBool(buf []byte, offset flatbuffers.UOffsetT) *Bool { 30 | n := flatbuffers.GetUOffsetT(buf[offset:]) 31 | x := &Bool{} 32 | x.Init(buf, n+offset) 33 | return x 34 | } 35 | 36 | func (rcv *Bool) Init(buf []byte, i flatbuffers.UOffsetT) { 37 | rcv._tab.Bytes = buf 38 | rcv._tab.Pos = i 39 | } 40 | 41 | func (rcv *Bool) Table() flatbuffers.Table { 42 | return rcv._tab 43 | } 44 | 45 | func BoolStart(builder *flatbuffers.Builder) { 46 | builder.StartObject(0) 47 | } 48 | func BoolEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 49 | return builder.EndObject() 50 | } 51 | -------------------------------------------------------------------------------- /arrow/internal/flatbuf/Endianness.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 18 | 19 | package flatbuf 20 | 21 | import "strconv" 22 | 23 | /// ---------------------------------------------------------------------- 24 | /// Endianness of the platform producing the data 25 | type Endianness int16 26 | 27 | const ( 28 | EndiannessLittle Endianness = 0 29 | EndiannessBig Endianness = 1 30 | ) 31 | 32 | var EnumNamesEndianness = map[Endianness]string{ 33 | EndiannessLittle: "Little", 34 | EndiannessBig: "Big", 35 | } 36 | 37 | var EnumValuesEndianness = map[string]Endianness{ 38 | "Little": EndiannessLittle, 39 | "Big": EndiannessBig, 40 | } 41 | 42 | func (v Endianness) String() string { 43 | if s, ok := EnumNamesEndianness[v]; ok { 44 | return s 45 | } 46 | return "Endianness(" + strconv.FormatInt(int64(v), 10) + ")" 47 | } 48 | -------------------------------------------------------------------------------- /arrow/internal/flatbuf/List.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 18 | 19 | package flatbuf 20 | 21 | import ( 22 | flatbuffers "github.com/google/flatbuffers/go" 23 | ) 24 | 25 | type List struct { 26 | _tab flatbuffers.Table 27 | } 28 | 29 | func GetRootAsList(buf []byte, offset flatbuffers.UOffsetT) *List { 30 | n := flatbuffers.GetUOffsetT(buf[offset:]) 31 | x := &List{} 32 | x.Init(buf, n+offset) 33 | return x 34 | } 35 | 36 | func (rcv *List) Init(buf []byte, i flatbuffers.UOffsetT) { 37 | rcv._tab.Bytes = buf 38 | rcv._tab.Pos = i 39 | } 40 | 41 | func (rcv *List) Table() flatbuffers.Table { 42 | return rcv._tab 43 | } 44 | 45 | func ListStart(builder *flatbuffers.Builder) { 46 | builder.StartObject(0) 47 | } 48 | func ListEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 49 | return builder.EndObject() 50 | } 51 | -------------------------------------------------------------------------------- /examples/sql/create_table/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "log" 6 | "os" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/sqldriver" 9 | ) 10 | 11 | func main() { 12 | config, err := sqldriver.NewConfigFromIni(os.Args[1]) 13 | if err != nil { 14 | log.Fatalf("%+v", err) 15 | } 16 | 17 | dsn := config.FormatDsn() 18 | // or dsn := "http://:@?project=" 19 | 20 | db, err := sql.Open("odps", dsn) 21 | if err != nil { 22 | log.Fatalf("%+v", err) 23 | } 24 | 25 | sqlStr := "create table if not exists all_types_demo (" + 26 | " tiny_int_type tinyint," + 27 | " small_int_type smallint," + 28 | " int_type int," + 29 | " bigint_type bigint," + 30 | " binary_type binary," + 31 | " float_type float," + 32 | " double_type double," + 33 | " decimal_type decimal(10, 8)," + 34 | " varchar_type varchar(500)," + 35 | " char_type varchar(254)," + 36 | " string_type string," + 37 | " date_type date," + 38 | " datetime_type datetime," + 39 | " timestamp_type timestamp," + 40 | " timestamp_ntz_type timestamp_ntz," + 41 | " boolean_type boolean," + 42 | " map_type map," + 43 | " array_type array< string>," + 44 | " struct_type struct, name:STRING>," + 45 | " json_type json" + 46 | ") " + 47 | "partitioned by (p1 bigint, p2 string);" 48 | 49 | _, err = db.Exec(sqlStr) 50 | if err != nil { 51 | log.Fatalf("%+v", err) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/sdk/tunnel/download_data_use_protoc_with_quota/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 10 | "github.com/aliyun/aliyun-odps-go-sdk/odps/data" 11 | tunnel2 "github.com/aliyun/aliyun-odps-go-sdk/odps/tunnel" 12 | ) 13 | 14 | func main() { 15 | conf, err := odps.NewConfigFromIni(os.Args[1]) 16 | if err != nil { 17 | log.Fatalf("%+v", err) 18 | } 19 | 20 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 21 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 22 | odpsIns.SetDefaultProjectName(conf.ProjectName) 23 | tunnel := tunnel2.NewTunnel(odpsIns) 24 | tunnel.SetQuotaName(conf.TunnelQuotaName) 25 | 26 | session, err := tunnel.CreateDownloadSession( 27 | conf.ProjectName, 28 | "mf_test", 29 | ) 30 | if err != nil { 31 | log.Fatalf("%+v", err) 32 | } 33 | fmt.Printf("tunnel endpoint: %+v\n", tunnel.GetEndpoint()) 34 | 35 | schema := session.Schema() 36 | recordCount := session.RecordCount() 37 | 38 | recordReader, err := session.OpenRecordReader(0, recordCount, nil) 39 | 40 | recordReader.Iterator(func(record data.Record, err error) { 41 | if err != nil { 42 | log.Fatalf("%+v", err) 43 | } 44 | 45 | for i, d := range record { 46 | if d == nil { 47 | fmt.Printf("%s=null", schema.Columns[i].Name) 48 | } else { 49 | fmt.Printf("%s=%s", schema.Columns[i].Name, d.Sql()) 50 | } 51 | 52 | if i < record.Len()-1 { 53 | fmt.Printf(", ") 54 | } else { 55 | fmt.Println() 56 | } 57 | } 58 | }) 59 | 60 | if err = recordReader.Close(); err != nil { 61 | log.Fatalf("%+v", err) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /examples/sdk/table/auto_partition_table/main.go: -------------------------------------------------------------------------------- 1 | package auto_partition_table 2 | 3 | import ( 4 | "log" 5 | "time" 6 | 7 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/data" 10 | ) 11 | 12 | func main() { 13 | // Specify the ini file path 14 | configPath := "./config.ini" 15 | conf, err := odps.NewConfigFromIni(configPath) 16 | if err != nil { 17 | log.Fatalf("%+v", err) 18 | } 19 | 20 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 21 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 22 | // Set the Default MaxCompute project used By Odps instance 23 | odpsIns.SetDefaultProjectName(conf.ProjectName) 24 | 25 | // Create Auto Partition Table 26 | ins, err := odpsIns.ExecSQl("create table if not exists auto_pt(a bigint, d timestamp) auto partitioned by (trunc_time(d, 'day') as part_value);", 27 | map[string]string{"odps.sql.type.system.odps2": "true"}) 28 | if err != nil { 29 | return 30 | } 31 | err = ins.WaitForSuccess() 32 | if err != nil { 33 | return 34 | } 35 | 36 | // Load Table 37 | table := odpsIns.Table("auto_pt") 38 | err = table.Load() 39 | if err != nil { 40 | log.Fatal(err) 41 | } 42 | pc := table.PartitionColumns() 43 | println(pc[0].GenerateExpression.String()) // trunc_time(d, 'day') 44 | 45 | // Get PartitionSpec From Record 46 | record := data.NewRecord(2) 47 | record[0] = data.BigInt(1) 48 | record[1] = data.Timestamp(time.Date(2023, 12, 25, 9, 0, 0, 0, time.UTC)) 49 | 50 | schema := table.Schema() 51 | partitionSpec, err := schema.GeneratePartitionSpec(&record) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | println(partitionSpec) 56 | } 57 | -------------------------------------------------------------------------------- /arrow/internal/flatbuf/Utf8.go: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // Code generated by the FlatBuffers compiler. DO NOT EDIT. 18 | 19 | package flatbuf 20 | 21 | import ( 22 | flatbuffers "github.com/google/flatbuffers/go" 23 | ) 24 | 25 | /// Unicode with UTF-8 encoding 26 | type Utf8 struct { 27 | _tab flatbuffers.Table 28 | } 29 | 30 | func GetRootAsUtf8(buf []byte, offset flatbuffers.UOffsetT) *Utf8 { 31 | n := flatbuffers.GetUOffsetT(buf[offset:]) 32 | x := &Utf8{} 33 | x.Init(buf, n+offset) 34 | return x 35 | } 36 | 37 | func (rcv *Utf8) Init(buf []byte, i flatbuffers.UOffsetT) { 38 | rcv._tab.Bytes = buf 39 | rcv._tab.Pos = i 40 | } 41 | 42 | func (rcv *Utf8) Table() flatbuffers.Table { 43 | return rcv._tab 44 | } 45 | 46 | func Utf8Start(builder *flatbuffers.Builder) { 47 | builder.StartObject(0) 48 | } 49 | func Utf8End(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 50 | return builder.EndObject() 51 | } 52 | -------------------------------------------------------------------------------- /examples/sdk/table/table_schema/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "strings" 7 | 8 | "github.com/aliyun/aliyun-odps-go-sdk/odps" 9 | "github.com/aliyun/aliyun-odps-go-sdk/odps/account" 10 | ) 11 | 12 | func main() { 13 | // Specify the ini file path 14 | configPath := "./config.ini" 15 | conf, err := odps.NewConfigFromIni(configPath) 16 | if err != nil { 17 | log.Fatalf("%+v", err) 18 | } 19 | 20 | aliAccount := account.NewAliyunAccount(conf.AccessId, conf.AccessKey) 21 | odpsIns := odps.NewOdps(aliAccount, conf.Endpoint) 22 | // Set the Default Maxcompute project used By Odps instance 23 | odpsIns.SetDefaultProjectName(conf.ProjectName) 24 | 25 | project := odpsIns.Project(conf.ProjectName) 26 | tables := project.Tables() 27 | table := tables.Get("test_cluster_table") 28 | 29 | err = table.Load() 30 | if err != nil { 31 | log.Fatalf("%+v", err) 32 | } 33 | 34 | // Get table schema 35 | schema := table.Schema() 36 | 37 | println("table name = ", schema.TableName) 38 | if table.LifeCycle() > 0 { 39 | println("table lifecycle = ", table.LifeCycle()) 40 | } 41 | 42 | // Get columns 43 | for _, c := range schema.Columns { 44 | fmt.Printf("column %s %s comment '%s'\n", c.Name, c.Type, c.Comment) 45 | } 46 | 47 | // Get partition columns 48 | for _, c := range schema.PartitionColumns { 49 | fmt.Printf("partition column %s %s comment '%s'\n", c.Name, c.Type, c.Comment) 50 | } 51 | 52 | // Get cluster information 53 | if schema.ClusterInfo.ClusterType != "" { 54 | ci := schema.ClusterInfo 55 | println("cluster type = ", ci.ClusterType) 56 | println("cluster columns = ", strings.Join(ci.ClusterCols, ", ")) 57 | println("cluster bucket num = ", ci.BucketNum) 58 | } 59 | } 60 | --------------------------------------------------------------------------------