Documentation ¶
Index ¶
- Constants
- Variables
- func ResourceTypeToStr(resourceType ResourceType) string
- type AdminTask
- type ArchiveResource
- type Cluster
- type ColumnMaskInfo
- type Config
- type FResource
- type FileResource
- type Function
- func (f *Function) ClassPath() string
- func (f *Function) Code() string
- func (f *Function) CreationTime() time.Time
- func (f *Function) Exist() (bool, error)
- func (f *Function) IsEmbeddedFunction() bool
- func (f *Function) IsSQLFunction() bool
- func (f *Function) Load() error
- func (f *Function) Name() string
- func (f *Function) Owner() string
- func (f *Function) ProgramLanguage() string
- func (f *Function) Project() string
- func (f *Function) Resources() []string
- func (f *Function) SQLDefinitionText() string
- func (f *Function) SchemaName() string
- func (f *Function) SetClassPath(classPath string)
- func (f *Function) SetName(name string)
- func (f *Function) SetResources(resources []string)
- type FunctionBuilder
- func (fb *FunctionBuilder) Build() Function
- func (fb *FunctionBuilder) ClassPath(classPath string) *FunctionBuilder
- func (fb *FunctionBuilder) Code(code string) *FunctionBuilder
- func (fb *FunctionBuilder) CreationTime(creationTime common.GMTTime) *FunctionBuilder
- func (fb *FunctionBuilder) FileName(fileName string) *FunctionBuilder
- func (fb *FunctionBuilder) IsEmbeddedFunction(isEmbeddedFunction bool) *FunctionBuilder
- func (fb *FunctionBuilder) IsSQLFunction(isSQLFunction bool) *FunctionBuilder
- func (fb *FunctionBuilder) Name(name string) *FunctionBuilder
- func (fb *FunctionBuilder) Odps(odpsIns *Odps) *FunctionBuilder
- func (fb *FunctionBuilder) Owner(owner string) *FunctionBuilder
- func (fb *FunctionBuilder) ProgramLanguage(programLanguage string) *FunctionBuilder
- func (fb *FunctionBuilder) ProjectName(projectName string) *FunctionBuilder
- func (fb *FunctionBuilder) Resources(resources []string) *FunctionBuilder
- func (fb *FunctionBuilder) SQLDefinitionText(sqlDefinitionText string) *FunctionBuilder
- func (fb *FunctionBuilder) SchemaName(schemaName string) *FunctionBuilder
- type Functions
- func (f *Functions) Create(projectName, schemaName string, function Function) error
- func (f *Functions) Delete(functionName string) error
- func (f *Functions) Get(functionName string) (*Function, error)
- func (f *Functions) ProjectName() string
- func (f *Functions) SchemaName() string
- func (f *Functions) Update(projectName, schemaName string, function Function) error
- type InsFilterFunc
- type Instance
- func (instance *Instance) EndTime() time.Time
- func (instance *Instance) GetCachedInfo() (string, error)
- func (instance *Instance) GetResult() ([]TaskResult, error)
- func (instance *Instance) GetTaskDetail(taskName string) ([]byte, error)
- func (instance *Instance) GetTaskProgress(taskName string) ([]TaskProgressStage, error)
- func (instance *Instance) GetTaskQuotaJson(taskName string) (string, error)
- func (instance *Instance) GetTaskSummary(taskName string) (*TaskSummary, error)
- func (instance *Instance) GetTasks() ([]TaskInInstance, error)
- func (instance *Instance) Id() string
- func (instance *Instance) IsAsync() bool
- func (instance *Instance) IsLoaded() bool
- func (instance *Instance) IsSync() bool
- func (instance *Instance) Load() error
- func (instance *Instance) Owner() string
- func (instance *Instance) ProjectName() string
- func (instance *Instance) StartTime() time.Time
- func (instance *Instance) Status() InstanceStatus
- func (instance *Instance) TaskNameCommitted() string
- func (instance *Instance) TaskResults() []TaskResult
- func (instance *Instance) Terminate() error
- func (instance *Instance) WaitForSuccess() error
- type InstanceOrErr
- type InstanceStatus
- type Instances
- func (instances *Instances) CreateTask(projectName string, task Task, ...) (*Instance, error)
- func (instances *Instances) CreateTaskWithPriority(projectName string, task Task, jobPriority int) (*Instance, error)
- func (instances *Instances) Get(instanceId string) *Instance
- func (instances *Instances) List(f func(*Instance), filters ...InsFilterFunc) error
- func (instances *Instances) ListInstancesQueued(filters ...InsFilterFunc) ([]string, error)
- type JarResource
- type LogView
- type MergeTask
- type Odps
- func (odps *Odps) Account() account2.Account
- func (odps *Odps) CurrentSchemaName() string
- func (odps *Odps) DefaultProject() *Project
- func (odps *Odps) DefaultProjectName() string
- func (odps *Odps) ExecSQl(sql string, hints ...map[string]string) (*Instance, error)
- func (odps *Odps) ExecSQlWithHints(sql string, hints map[string]string) (*Instance, error)
- func (odps *Odps) ExecSQlWithOption(sql string, option *options.SQLTaskOptions) (*Instance, error)
- func (odps *Odps) Instance(instanceId string) *Instance
- func (odps *Odps) Instances() *Instances
- func (odps *Odps) LogView() *LogView
- func (odps *Odps) Project(name string) *Project
- func (odps *Odps) Projects() *Projects
- func (odps *Odps) RestClient() restclient.RestClient
- func (odps *Odps) Schema(name string) *Schema
- func (odps *Odps) Schemas() *Schemas
- func (odps *Odps) SetCurrentSchemaName(schemaName string)
- func (odps *Odps) SetDefaultProjectName(projectName string)
- func (odps *Odps) SetHttpTimeout(t time.Duration)
- func (odps *Odps) SetTcpConnectTimeout(t time.Duration)
- func (odps *Odps) SetUserAgent(userAgent string)
- func (odps *Odps) Table(name string) *Table
- func (odps *Odps) Tables() *Tables
- type OptionalQuota
- type PFilterFunc
- type Partition
- func (p *Partition) CreatedTime() time.Time
- func (p *Partition) FileNumEx() int
- func (p *Partition) IsArchivedEx() bool
- func (p *Partition) LastDDLTime() time.Time
- func (p *Partition) LastModifiedTime() time.Time
- func (p *Partition) LifeCycleEx() int
- func (p *Partition) Load() error
- func (p *Partition) LoadExtended() error
- func (p *Partition) Name() stringdeprecated
- func (p *Partition) PhysicalSizeEx() int
- func (p *Partition) RecordNum() int
- func (p *Partition) ReservedEx() string
- func (p *Partition) Size() int
- func (p *Partition) Spec() string
- func (p *Partition) Value() string
- type PartitionColumn
- type Project
- func (p *Project) Comment() string
- func (p *Project) CreationTime() time.Time
- func (p *Project) Existed() bool
- func (p *Project) GetAllProperties() (common.Properties, error)
- func (p *Project) GetClusters() ([]Cluster, error)
- func (p *Project) GetDefaultCluster() (string, error)
- func (p *Project) GetExtendedProperties() (common.Properties, error)
- func (p *Project) GetTunnelEndpoint(quotaNames ...string) (string, error)
- func (p *Project) IsLoaded() bool
- func (p *Project) LastModifiedTime() time.Time
- func (p *Project) Load() error
- func (p *Project) Name() string
- func (p *Project) OdpsIns() *Odps
- func (p *Project) Owner() string
- func (p *Project) ProjectGroupName() string
- func (p *Project) PropertiesHasBeSet() common.Properties
- func (p *Project) RestClient() restclient.RestClient
- func (p *Project) Schemas() *Schemas
- func (p *Project) SecurityManager() security.Manager
- func (p *Project) Status() ProjectStatus
- func (p *Project) Tables() *Tables
- func (p *Project) Type() string
- func (p *Project) Update(properties map[string]string) error
- type ProjectStatus
- type Projects
- func (p *Projects) CreateExternalProject(projectName string) error
- func (p *Projects) DeleteExternalProject(projectName string) error
- func (p *Projects) Exists(projectName string) (bool, error)
- func (p *Projects) Get(projectName string) *Project
- func (p *Projects) GetDefaultProject() *Project
- func (p *Projects) List(filters ...PFilterFunc) ([]*Project, error)
- func (p *Projects) UpdateProject(projectName string) error
- type PyResource
- type RFileFunc
- type ReaderResource
- type Resource
- func (r *Resource) Comment() string
- func (r *Resource) Exist() (bool, error)
- func (r *Resource) IsTempResource() bool
- func (r *Resource) Load() error
- func (r *Resource) Name() string
- func (r *Resource) ResourceType() ResourceType
- func (r *Resource) SchemaName() string
- func (r *Resource) SetComment(comment string)
- func (r *Resource) SetIsTempResource(isTempResource bool)
- func (r *Resource) SetName(name string)
- func (r *Resource) SetResourceType(resourceType ResourceType)
- type ResourceType
- type Resources
- func (r *Resources) CreateFileResource(projectName, schemaName string, lfr ReaderResource, overwrite bool) error
- func (r *Resources) CreateTableResource(projectName, schemaName string, tr TableResource, overwrite bool) error
- func (r *Resources) Delete(resourceName string) error
- func (r *Resources) Get(resourceName string) *Resource
- func (r *Resources) List(f func(*Resource, error), filters ...RFileFunc)
- func (r *Resources) UpdateFileResource(projectName, schemaName string, lfr ReaderResource) error
- type SQLCostTask
- type SQLPlanTask
- type SQLRTTask
- type SQLTask
- type Schema
- func (s *Schema) ChangeComment(newComment string) error
- func (s *Schema) ChangeOwner(newOwner string) error
- func (s *Schema) Comment() string
- func (s *Schema) CreateTime() time.Time
- func (s *Schema) Exists() (bool, error)
- func (s *Schema) IsLoaded() bool
- func (s *Schema) Load() error
- func (s *Schema) ModifiedTime() time.Time
- func (s *Schema) Name() string
- func (s *Schema) Owner() string
- func (s *Schema) ProjectName() string
- func (s *Schema) ResourceUrl() string
- func (s *Schema) Tables() *Tables
- func (s *Schema) Type() string
- type Schemas
- type TFilterFunc
- type Table
- func (t *Table) AddColumns(columns []tableschema.Column, ifNotExists bool) error
- func (t *Table) AddPartition(ifNotExists bool, partitionValue string) error
- func (t *Table) AddPartitions(ifNotExists bool, partitionValues []string) error
- func (t *Table) AlterColumnType(columnName string, columnType datatype.DataType) error
- func (t *Table) ChangeClusterInfo(clusterInfo tableschema.ClusterInfo) error
- func (t *Table) ChangeColumnName(oldColumnName string, newColumnName string) error
- func (t *Table) ChangeComment(newComment string) error
- func (t *Table) ChangeOwner(newOwner string) error
- func (t *Table) ClusterInfo() tableschema.ClusterInfo
- func (t *Table) ColumnMaskInfos() ([]ColumnMaskInfo, error)
- func (t *Table) Comment() string
- func (t *Table) CreatedTime() time.Time
- func (t *Table) CryptoAlgo() string
- func (t *Table) Delete() error
- func (t *Table) DeletePartition(ifExists bool, partitionValue string) error
- func (t *Table) DeletePartitions(ifExists bool, partitionValues []string) error
- func (t *Table) DropColumns(columnNames []string) error
- func (t *Table) ExecSql(taskName, sql string) (*Instance, error)
- func (t *Table) ExecSqlWithHints(taskName, sql string, hints map[string]string) (*Instance, error)
- func (t *Table) Exists() (bool, error)
- func (t *Table) GetPartition(partitionValue string) (Partition, error)
- func (t *Table) GetPartitionValues() ([]string, error)
- func (t *Table) GetPartitions() ([]Partition, error)
- func (t *Table) HubLifeCycle() int
- func (t *Table) IsLoaded() bool
- func (t *Table) IsLoadedExtended() bool
- func (t *Table) LastDDLTime() time.Time
- func (t *Table) LastModifiedTime() time.Time
- func (t *Table) LifeCycle() int
- func (t *Table) Load() error
- func (t *Table) LoadExtendedInfo() error
- func (t *Table) MaxExtendedLabel() string
- func (t *Table) MaxLabel() string
- func (t *Table) Name() string
- func (t *Table) Owner() string
- func (t *Table) PartitionColumns() []tableschema.Column
- func (t *Table) PrimaryKeys() []string
- func (t *Table) ProjectName() string
- func (t *Table) RecordNum() int
- func (t *Table) Rename(newName string) error
- func (t *Table) ResourceUrl() string
- func (t *Table) Schema() tableschema.TableSchema
- func (t *Table) SchemaJson() string
- func (t *Table) SchemaName() string
- func (t *Table) SetLifeCycle(days int) error
- func (t *Table) ShardInfoJson() string
- func (t *Table) Size() int64
- func (t *Table) TableExtendedLabels() []string
- func (t *Table) TableID() string
- func (t *Table) TableLabel() string
- func (t *Table) Touch() error
- func (t *Table) Transactional() bool
- func (t *Table) Truncate() error
- func (t *Table) Type() TableType
- func (t *Table) ViewText() string
- type TableOrErr
- type TableResource
- type TableType
- type Tables
- func (ts *Tables) BatchLoadTables(tableNames []string) ([]*Table, error)
- func (ts *Tables) Create(schema tableschema.TableSchema, createIfNotExists bool, ...) error
- func (ts *Tables) CreateExternal(schema tableschema.TableSchema, createIfNotExists bool, ...) error
- func (ts *Tables) CreateView(schema tableschema.TableSchema, ...) error
- func (ts *Tables) CreateWithDataHub(schema tableschema.TableSchema, createIfNotExists bool, ...) error
- func (ts *Tables) Delete(tableName string, ifExists bool) error
- func (ts *Tables) Get(tableName string) *Table
- func (ts *Tables) List(f func(*Table, error), filters ...TFilterFunc)
- type Task
- type TaskConfig
- type TaskInInstance
- type TaskName
- type TaskProgressStage
- type TaskResult
- type TaskStatus
- type TaskSummary
Examples ¶
- Instance.GetCachedInfo
- Instance.GetTaskProgress
- Instance.GetTaskSummary
- Instance.Terminate
- Instances.CreateTask
- Instances.List
- Instances.ListInstancesQueued
- Partition.Load
- Partition.LoadExtended
- Project
- Project.GetTunnelEndpoint
- Projects.Exists
- Projects.List
- Table.AddPartition
- Table.ExecSql
- Table.GetPartitions
- Table.Load
- Tables.BatchLoadTables
- Tables.Create
- Tables.Delete
- Tables.List
Constants ¶
const ( TaskWaiting TaskRunning TaskSuccess TaskFailed TaskSuspended TaskCancelled TaskStatusUnknown )
const ( ProjectStatusAvailable ProjectStatusReadOnly ProjectStatusDeleting ProjectStatusFrozen ProjectStatusUnKnown )
const ( // ProjectTypeManaged ordinary project ProjectTypeManaged = "managed" // ProjectExternalExternal external project,like hive ProjectExternalExternal = "external" )
const DefaultJobPriority = 9
const (
HostDefault = "https://logview.alibaba-inc.com"
)
Variables ¶
var InstanceFilter = struct { // Only get instances with a given status Status func(InstanceStatus) InsFilterFunc // Only get instances that create by the current account OnlyOwner func() InsFilterFunc // Instance 运行所在 quota 组过滤条件 QuotaIndex func(string) InsFilterFunc // Get instances running between start and end times TimeRange func(time.Time, time.Time) InsFilterFunc }{ Status: func(status InstanceStatus) InsFilterFunc { return func(values url.Values) { if status != 0 { values.Set("status", status.String()) } } }, OnlyOwner: func() InsFilterFunc { return func(values url.Values) { values.Set("onlyowner", "yes") } }, QuotaIndex: func(s string) InsFilterFunc { return func(values url.Values) { values.Set("quotaindex", s) } }, TimeRange: func(s time.Time, e time.Time) InsFilterFunc { return func(values url.Values) { startTime := strconv.FormatInt(s.Unix(), 10) endTime := strconv.FormatInt(e.Unix(), 10) dateRange := fmt.Sprintf("%s:%s", startTime, endTime) values.Set("daterange", dateRange) } }, }
var ProjectFilter = struct { // Filter out projects with a name prefix NamePrefix func(string) PFilterFunc // Filter out projects with project owner name, this filter cannot be used with `User` together Owner func(string) PFilterFunc // Filter out projects with a project member name User func(string) PFilterFunc // Filter out projects with the project group name Group func(string) PFilterFunc }{ NamePrefix: withProjectNamePrefix, Owner: withProjectOwner, User: withUserInProject, Group: withProjectGroup, }
var ResourceFilter = struct { // Filter out resources with name prefix NamePrefix func(string) TFilterFunc }{ NamePrefix: func(name string) TFilterFunc { return func(values url.Values) { values.Set("name", name) } }, }
ResourceFilter is a filter for resources
var TableFilter = struct { // Weather get extended information or not Extended func() TFilterFunc // Filter out tables with name prefix NamePrefix func(string) TFilterFunc // Filter out tables with owner name Owner func(string) TFilterFunc // Filter out tables with table type Type func(TableType) TFilterFunc }{ Extended: func() TFilterFunc { return func(values url.Values) { values.Set("extended", "") } }, NamePrefix: func(name string) TFilterFunc { return func(values url.Values) { values.Set("name", name) } }, Owner: func(owner string) TFilterFunc { return func(values url.Values) { values.Set("owner", owner) } }, Type: func(tableType TableType) TFilterFunc { return func(values url.Values) { values.Set("type", tableType.String()) } }, }
Functions ¶
func ResourceTypeToStr ¶ added in v0.4.1
func ResourceTypeToStr(resourceType ResourceType) string
ResourceTypeToStr convert ResourceType to string
Types ¶
type AdminTask ¶ added in v0.3.3
type AdminTask struct { XMLName xml.Name `xml:"Admin"` TaskName `xml:"Name"` // 注意: TaskConfig和Command的顺序不能更改 TaskConfig Command string `xml:"Command"` }
func NewAdminTask ¶ added in v0.3.3
type ArchiveResource ¶ added in v0.4.1
type ArchiveResource struct {
FileResource
}
ArchiveResource is a archive resource
func NewArchiveResource ¶ added in v0.4.1
func NewArchiveResource(resourceName string) *ArchiveResource
NewArchiveResource create a new ArchiveResource
type Cluster ¶
type Cluster struct { Name string `xml:"Name"` QuotaId string `xml:"QuotaId"` Quotas []OptionalQuota `xml:"Quotas"` }
type ColumnMaskInfo ¶ added in v0.3.17
type ColumnMaskInfo struct { Name string // Column Name PolicyNameList []string // Data policy names bind with column }
ColumnMaskInfo is used for the return value of Table.ColumnMaskInfos
type Config ¶
type Config struct { AccessId string AccessKey string StsToken string Endpoint string ProjectName string TcpConnectionTimeout time.Duration HttpTimeout time.Duration TunnelEndpoint string TunnelQuotaName string Hints map[string]string Others map[string]string }
Config is the basic config for odps. The NewConfig function should be used, which sets default values.
func NewConfigFromIni ¶
func (*Config) GenAccount ¶
func (*Config) GenRestClient ¶
func (c *Config) GenRestClient() restclient.RestClient
type FResource ¶ added in v0.4.1
type FResource struct {
ResourceName string `xml:"ResourceName,omitempty"`
}
FResource is a resource for function
type FileResource ¶ added in v0.4.1
type FileResource struct { Resource // contains filtered or unexported fields }
FileResource is a file resource
func NewFileResource ¶ added in v0.4.1
func NewFileResource(resourceName string) *FileResource
NewFileResource create a new FileResource
func (*FileResource) Reader ¶ added in v0.4.1
func (fr *FileResource) Reader() io.Reader
Reader get reader
func (*FileResource) SetReader ¶ added in v0.4.1
func (fr *FileResource) SetReader(reader io.Reader)
SetReader set reader
type Function ¶ added in v0.4.1
type Function struct { ProjectName string OdpsIns *Odps Model functionModel // contains filtered or unexported fields }
Function is a function
func (*Function) CreationTime ¶ added in v0.4.1
CreationTime get function creation time
func (*Function) IsEmbeddedFunction ¶ added in v0.4.1
IsEmbeddedFunction get whether function is embedded function
func (*Function) IsSQLFunction ¶ added in v0.4.1
IsSQLFunction get whether function is sql function
func (*Function) ProgramLanguage ¶ added in v0.4.1
ProgramLanguage get function program language
func (*Function) SQLDefinitionText ¶ added in v0.4.1
SQLDefinitionText get function sql definition text
func (*Function) SchemaName ¶ added in v0.4.1
SchemaName get function schema name
func (*Function) SetClassPath ¶ added in v0.4.1
SetClassPath set function class path
func (*Function) SetResources ¶ added in v0.4.1
SetResources set function resources
type FunctionBuilder ¶ added in v0.4.1
type FunctionBuilder struct {
// contains filtered or unexported fields
}
FunctionBuilder is a builder for Function
func NewFunctionBuilder ¶ added in v0.4.1
func NewFunctionBuilder() *FunctionBuilder
NewFunctionBuilder create a new FunctionBuilder
func (*FunctionBuilder) Build ¶ added in v0.4.1
func (fb *FunctionBuilder) Build() Function
Build build a Function
func (*FunctionBuilder) ClassPath ¶ added in v0.4.1
func (fb *FunctionBuilder) ClassPath(classPath string) *FunctionBuilder
ClassPath set function class path
func (*FunctionBuilder) Code ¶ added in v0.4.1
func (fb *FunctionBuilder) Code(code string) *FunctionBuilder
Code set function code
func (*FunctionBuilder) CreationTime ¶ added in v0.4.1
func (fb *FunctionBuilder) CreationTime(creationTime common.GMTTime) *FunctionBuilder
CreationTime set function creation time
func (*FunctionBuilder) FileName ¶ added in v0.4.1
func (fb *FunctionBuilder) FileName(fileName string) *FunctionBuilder
FileName set function file name
func (*FunctionBuilder) IsEmbeddedFunction ¶ added in v0.4.1
func (fb *FunctionBuilder) IsEmbeddedFunction(isEmbeddedFunction bool) *FunctionBuilder
IsEmbeddedFunction set whether function is embedded function
func (*FunctionBuilder) IsSQLFunction ¶ added in v0.4.1
func (fb *FunctionBuilder) IsSQLFunction(isSQLFunction bool) *FunctionBuilder
IsSQLFunction set whether function is sql function
func (*FunctionBuilder) Name ¶ added in v0.4.1
func (fb *FunctionBuilder) Name(name string) *FunctionBuilder
Name set function name
func (*FunctionBuilder) Odps ¶ added in v0.4.1
func (fb *FunctionBuilder) Odps(odpsIns *Odps) *FunctionBuilder
Odps set function odps
func (*FunctionBuilder) Owner ¶ added in v0.4.1
func (fb *FunctionBuilder) Owner(owner string) *FunctionBuilder
Owner set function owner
func (*FunctionBuilder) ProgramLanguage ¶ added in v0.4.1
func (fb *FunctionBuilder) ProgramLanguage(programLanguage string) *FunctionBuilder
ProgramLanguage set function program language
func (*FunctionBuilder) ProjectName ¶ added in v0.4.1
func (fb *FunctionBuilder) ProjectName(projectName string) *FunctionBuilder
ProjectName set function project name
func (*FunctionBuilder) Resources ¶ added in v0.4.1
func (fb *FunctionBuilder) Resources(resources []string) *FunctionBuilder
Resources set function resources
func (*FunctionBuilder) SQLDefinitionText ¶ added in v0.4.1
func (fb *FunctionBuilder) SQLDefinitionText(sqlDefinitionText string) *FunctionBuilder
SQLDefinitionText set function sql definition text
func (*FunctionBuilder) SchemaName ¶ added in v0.4.1
func (fb *FunctionBuilder) SchemaName(schemaName string) *FunctionBuilder
SchemaName set function schema name
type Functions ¶ added in v0.4.1
type Functions struct { OdpsIns *Odps // contains filtered or unexported fields }
Functions is used for the functions in odps projects
func NewFunctions ¶ added in v0.4.1
NewFunctions create a new Functions
func (*Functions) ProjectName ¶ added in v0.4.1
ProjectName get the project name
func (*Functions) SchemaName ¶ added in v0.4.1
SchemaName get the schema name
type InsFilterFunc ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
func NewInstance ¶
func (*Instance) GetCachedInfo ¶
GetCachedInfo 获取instance cached信息,返回的是json字符串,需要自己进行解析
Example ¶
instances := odps.NewInstances(odpsIns) sqlTask := odps.NewSqlTask("hello1", "select * from user;", nil) instance, err := instances.CreateTask(defaultProjectName, &sqlTask) if err != nil { log.Fatalf("%+v", err) } println(instance.Id()) i, err := instance.GetCachedInfo() if err != nil { log.Fatalf("%+v", err) } println(fmt.Sprintf("%+v", i))
Output:
func (*Instance) GetResult ¶
func (instance *Instance) GetResult() ([]TaskResult, error)
func (*Instance) GetTaskDetail ¶
func (*Instance) GetTaskProgress ¶
func (instance *Instance) GetTaskProgress(taskName string) ([]TaskProgressStage, error)
Example ¶
instances := odps.NewInstances(odpsIns) sqlTask := odps.NewSqlTask("hello", "select count(*) from sale_detail;", nil) instance, err := instances.CreateTask(defaultProjectName, &sqlTask) if err != nil { log.Fatalf("%+v", err) } println(instance.Id()) for i := 0; i < 5; i++ { progress, err := instance.GetTaskProgress("hello") if err != nil { log.Fatalf("%+v", err) } for _, stage := range progress { println(fmt.Sprintf("%+v", stage)) } time.Sleep(time.Second * 1) } body, err := instance.GetTaskDetail("hello") if err != nil { log.Fatalf("%+v", err) } println(string(body))
Output:
func (*Instance) GetTaskQuotaJson ¶
func (*Instance) GetTaskSummary ¶
func (instance *Instance) GetTaskSummary(taskName string) (*TaskSummary, error)
Example ¶
instances := odps.NewInstances(odpsIns) sqlTask := odps.NewSqlTask("hello1", "select count(*) from sale_detail;", nil) instance, err := instances.CreateTask(defaultProjectName, &sqlTask) if err != nil { log.Fatalf("%+v", err) } println(instance.Id()) _ = instance.WaitForSuccess() taskSummary, err := instance.GetTaskSummary("hello1") if err != nil { log.Fatalf("%+v", err) } println(fmt.Sprintf("%s\n%s\n", taskSummary.JsonSummary, taskSummary.Summary))
Output:
func (*Instance) GetTasks ¶
func (instance *Instance) GetTasks() ([]TaskInInstance, error)
GetTasks 绝大部分时候返回一个Task(名字与提交的task名字相同),返回多个task的情况我还没有遇到过
func (*Instance) ProjectName ¶
func (*Instance) Status ¶
func (instance *Instance) Status() InstanceStatus
func (*Instance) TaskNameCommitted ¶
func (*Instance) TaskResults ¶
func (instance *Instance) TaskResults() []TaskResult
func (*Instance) Terminate ¶
Example ¶
instances := odps.NewInstances(odpsIns) sqlTask := odps.NewSqlTask("hello", "select count(*) from user;", nil) instance, err := instances.CreateTask(defaultProjectName, &sqlTask) if err != nil { log.Fatalf("%+v", err) } println(instance.Id()) err = instance.Terminate() if err != nil { log.Fatalf("%+v", err) } err = instance.Load() if err != nil { log.Fatalf("%+v", err) } println(fmt.Sprintf("%s, %s, %s", instance.StartTime(), instance.EndTime(), instance.Status()))
Output:
func (*Instance) WaitForSuccess ¶
type InstanceOrErr ¶
InstanceOrErr is used for the return value of Instances.List
type InstanceStatus ¶
type InstanceStatus int
const ( InstanceRunning InstanceStatus InstanceSuspended InstanceTerminated InstanceStatusUnknown )
func InstancesStatusFromStr ¶
func InstancesStatusFromStr(s string) InstanceStatus
func (*InstanceStatus) MarshalXML ¶
func (status *InstanceStatus) MarshalXML(d *xml.Encoder, start xml.StartElement) error
func (InstanceStatus) String ¶
func (status InstanceStatus) String() string
func (*InstanceStatus) UnmarshalXML ¶
func (status *InstanceStatus) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type Instances ¶
type Instances struct {
// contains filtered or unexported fields
}
Instances is used to get or create instance(s)
func NewInstances ¶
NewInstances create Instances object, if the projectName is not set, the default project name of odpsIns will be used
func (*Instances) CreateTask ¶
func (instances *Instances) CreateTask(projectName string, task Task, createInstanceOptions ...*options.CreateInstanceOptions) (*Instance, error)
CreateTask Create a Task (maybe SQLTask) with options.CreateInstanceOptions
Example ¶
instances := odpsIns.Instances() sqlTask := odps.NewSqlTask("hello", "select count(*) from sale_detail;", nil) instance, err := instances.CreateTask(defaultProjectName, &sqlTask) if err != nil { log.Fatalf("%+v", err) } println(instance.Id()) err = instance.Load() if err != nil { log.Fatalf("%+v", err) } println(fmt.Sprintf("%s, %s, %s", instance.StartTime(), instance.EndTime(), instance.Status())) timeFormat := "2006-01-02 15:04:05" Loop: for { tasks, err := instance.GetTasks() task := tasks[0] if err != nil { log.Fatalf("%+v", err) } println( fmt.Sprintf( "%s, %s, %s, %s", task.StartTime.Format(timeFormat), task.EndTime.Format(timeFormat), task.Status, task.Name, )) switch task.Status { case odps.TaskCancelled, odps.TaskFailed, odps.TaskSuccess: break Loop } time.Sleep(time.Second * 2) } err = instance.Load() if err != nil { log.Fatalf("%+v", err) } body, err := instance.GetTaskDetail("hello") if err != nil { log.Fatalf("%+v", err) } println(string(body)) println( fmt.Sprintf( "%s, %s, %s", instance.StartTime().Format(timeFormat), instance.EndTime().Format(timeFormat), instance.Status(), ))
Output:
func (*Instances) CreateTaskWithPriority ¶
func (instances *Instances) CreateTaskWithPriority(projectName string, task Task, jobPriority int) (*Instance, error)
CreateTaskWithPriority Create a Task (maybe SQLTask) with specified priority
func (*Instances) List ¶
func (instances *Instances) List(f func(*Instance), filters ...InsFilterFunc) error
List Get all instances, the filters can be given with InstanceFilter.Status, InstanceFilter.OnlyOwner, InstanceFilter.QuotaIndex, InstanceFilter.TimeRange
Example ¶
ins := odpsIns.Instances() timeFormat := "2006-01-02 15:04:05" startTime, _ := time.Parse(timeFormat, "2021-11-15 02:15:30") endTime, _ := time.Parse(timeFormat, "2021-11-18 06:22:02") f := func(i *odps.Instance) { println( fmt.Sprintf( "%s, %s, %s, %s, %s", i.Id(), i.Owner(), i.StartTime().Format(timeFormat), i.EndTime().Format(timeFormat), i.Status(), )) } ins.List(f, odps.InstanceFilter.TimeRange(startTime, endTime))
Output:
func (*Instances) ListInstancesQueued ¶
func (instances *Instances) ListInstancesQueued(filters ...InsFilterFunc) ([]string, error)
ListInstancesQueued Get all instance Queued information, the information is in json string,you need parse it yourself。 The filters can be given with InstanceFilter.Status, InstanceFilter.OnlyOwner, InstanceFilter.QuotaIndex, InstanceFilter.TimeRange
Example ¶
ins := odpsIns.Instances() instances, err := ins.ListInstancesQueued() if err != nil { log.Fatalf("%+v", err) } for _, i := range instances { println(fmt.Sprintf("%+v", i)) }
Output:
type JarResource ¶ added in v0.4.1
type JarResource struct {
FileResource
}
JarResource is a jar resource
func NewJarResource ¶ added in v0.4.1
func NewJarResource(resourceName string) *JarResource
NewJarResource create a new JarResource
type LogView ¶
type LogView struct {
// contains filtered or unexported fields
}
func NewLogView ¶
func (*LogView) GenerateLogView ¶
func (*LogView) LogViewHost ¶
func (*LogView) SetLogViewHost ¶
type MergeTask ¶
type Odps ¶
type Odps struct {
// contains filtered or unexported fields
}
func (*Odps) CurrentSchemaName ¶ added in v0.3.8
func (*Odps) DefaultProject ¶
func (*Odps) DefaultProjectName ¶
func (*Odps) ExecSQlWithHints ¶
func (*Odps) ExecSQlWithOption ¶ added in v0.4.1
ExecSQlWithOption Create a SQLTask with options.SQLTaskOptions
func (*Odps) RestClient ¶
func (odps *Odps) RestClient() restclient.RestClient
func (*Odps) SetCurrentSchemaName ¶ added in v0.3.8
func (*Odps) SetDefaultProjectName ¶
func (*Odps) SetHttpTimeout ¶
func (*Odps) SetTcpConnectTimeout ¶
func (*Odps) SetUserAgent ¶
type OptionalQuota ¶
type OptionalQuota struct { XMLName xml.Name `xml:"OptionalQuota"` QuotaId string `xml:"QuotaID"` Properties common.Properties `xml:"Properties"` }
type PFilterFunc ¶
type Partition ¶
type Partition struct {
// contains filtered or unexported fields
}
Partition ODPS分区表中一个特定的分区
func NewPartition ¶
func NewPartition(odpsIns *Odps, projectName, schemaName, tableName string, value string) *Partition
NewPartition get partition object by table and partitionSpec, this method does not actually create a Partition in MaxCompute, but only obtains the Partition object.
func (*Partition) CreatedTime ¶
func (*Partition) IsArchivedEx ¶
func (*Partition) LastModifiedTime ¶
func (*Partition) LifeCycleEx ¶
func (*Partition) Load ¶
Example ¶
err := odpsIns.Table("sale_detail").AddPartitions(true, []string{"sale_date=201910/region=shanghai"}) if err != nil { log.Fatalf("%+v", err) } partition := odps.NewPartition(odpsIns, defaultProjectName, "", "sale_detail", "sale_date=201910/region=shanghai") err = partition.Load() if err != nil { log.Fatalf("%+v", err) } println(fmt.Sprintf("Value: %s", partition.Value())) println(fmt.Sprintf("Record number: %d", partition.RecordNum())) println(fmt.Sprintf("Create Time: %s", partition.CreatedTime()))
Output:
func (*Partition) LoadExtended ¶
Example ¶
err := odpsIns.Table("sale_detail").AddPartitions(true, []string{"sale_date=201910/region=shanghai"}) if err != nil { log.Fatalf("%+v", err) } partition := odps.NewPartition(odpsIns, defaultProjectName, "", "sale_detail", "sale_date=201910/region=shanghai") err = partition.LoadExtended() if err != nil { log.Fatalf("%+v", err) } println(fmt.Sprintf("Value: %s", partition.Value())) println(fmt.Sprintf("File number: %d", partition.FileNumEx())) println(fmt.Sprintf("PhysicalSizefd: %d", partition.PhysicalSizeEx())) println(fmt.Sprintf("Reserved: %s", partition.ReservedEx()))
Output:
func (*Partition) PhysicalSizeEx ¶
func (*Partition) ReservedEx ¶
ReservedEx 返回扩展信息的保留字段 json 字符串
type PartitionColumn ¶ added in v0.3.8
type Project ¶
type Project struct {
// contains filtered or unexported fields
}
Example ¶
projects := odpsIns.Projects() project := projects.Get(defaultProjectName) if err := project.Load(); err != nil { panic(err) } println(project.Status()) println(project.Owner()) creationTime := project.CreationTime() println(creationTime.Format(time.RFC1123)) lastModifiedTime := project.LastModifiedTime() println(lastModifiedTime.Format(time.RFC1123)) defaultCluster, _ := project.GetDefaultCluster() println(defaultCluster) println("************all properties") allProperties, _ := project.GetAllProperties() for _, p := range allProperties { println(p.Name, p.Value) } println("************extended properties") extendedProperties, _ := project.GetExtendedProperties() for _, p := range extendedProperties { println(p.Name, p.Value) } isExisted := project.Existed() println(isExisted)
Output:
func NewProject ¶
func (*Project) CreationTime ¶
func (*Project) GetAllProperties ¶
func (p *Project) GetAllProperties() (common.Properties, error)
GetAllProperties get all the configurable properties of the project, including the properties inherit from group. **note**, this method may return error when something wrong during loading data from the api serer
func (*Project) GetClusters ¶
GetClusters Get information of clusters owned by this project. This is an internal method for group-api. **note**, this method may return error when something wrong during loading data from the api serer
func (*Project) GetDefaultCluster ¶
GetDefaultCluster Get default cluster. This is an internal method for group-api. Returns efault cluster when called by group owner, otherwise ,null. **note**, this method may return error when something wrong during loading data from the api serer
func (*Project) GetExtendedProperties ¶
func (p *Project) GetExtendedProperties() (common.Properties, error)
GetExtendedProperties get the extended properties of the project **note**, this method may return error when something wrong during loading data from the api serer
func (*Project) GetTunnelEndpoint ¶
Example ¶
project := odpsIns.DefaultProject() tunnelEndpoint, err := project.GetTunnelEndpoint() if err != nil { log.Fatalf("%+v", err) } else { println(tunnelEndpoint) }
Output:
func (*Project) LastModifiedTime ¶
func (*Project) ProjectGroupName ¶
func (*Project) PropertiesHasBeSet ¶
func (p *Project) PropertiesHasBeSet() common.Properties
PropertiesHasBeSet Properties get the properties those have be set for the project
func (*Project) RestClient ¶
func (p *Project) RestClient() restclient.RestClient
func (*Project) SecurityManager ¶
func (*Project) Status ¶
func (p *Project) Status() ProjectStatus
type ProjectStatus ¶
type ProjectStatus int
func (*ProjectStatus) FromStr ¶
func (status *ProjectStatus) FromStr(s string)
func (ProjectStatus) MarshalXML ¶
func (status ProjectStatus) MarshalXML(d *xml.Encoder, start xml.StartElement) error
func (ProjectStatus) String ¶
func (status ProjectStatus) String() string
func (*ProjectStatus) UnmarshalXML ¶
func (status *ProjectStatus) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type Projects ¶
type Projects struct {
// contains filtered or unexported fields
}
func NewProjects ¶
func (*Projects) CreateExternalProject ¶
CreateExternalProject unimplemented!
func (*Projects) DeleteExternalProject ¶
DeleteExternalProject unimplemented!
func (*Projects) Exists ¶
Example ¶
projects := odpsIns.Projects() projectName := defaultProjectName existed, err := projects.Exists(projectName) if err != nil { log.Fatalf("%+v", err) } println(fmt.Sprintf("%s existed: %t", projectName, existed))
Output:
func (*Projects) GetDefaultProject ¶
func (*Projects) List ¶
func (p *Projects) List(filters ...PFilterFunc) ([]*Project, error)
List get all the projects thant current account can access in the specific endpoint filters can be specified with ProjectFilter.NamePrefix, ProjectFilter.Owner, ProjectFilter.User, ProjectFilter.Group
Example ¶
projectsIns := odpsIns.Projects() projects, err := projectsIns.List(odps.ProjectFilter.NamePrefix("p")) if err != nil { log.Fatalf("%+v", err) } for _, project := range projects { println(fmt.Sprintf("%+v", project)) }
Output:
func (*Projects) UpdateProject ¶
type PyResource ¶ added in v0.4.1
type PyResource struct {
FileResource
}
PyResource is a py resource
func NewPyResource ¶ added in v0.4.1
func NewPyResource(resourceName string) *PyResource
NewPyResource create a new PyResource
type ReaderResource ¶ added in v0.4.1
type ReaderResource interface { SetReader(reader io.Reader) Reader() io.Reader Name() string Comment() string IsTempResource() bool ResourceType() ResourceType }
ReaderResource is a resource that created with a reader
type Resource ¶ added in v0.4.1
type Resource struct { Model resourceModel ProjectName string OdpsIns *Odps // contains filtered or unexported fields }
Resource is a resource in odps
func NewResource ¶ added in v0.4.1
NewResource create a new Resource
func (*Resource) IsTempResource ¶ added in v0.4.1
IsTempResource get whether resource is temp resource
func (*Resource) ResourceType ¶ added in v0.4.1
func (r *Resource) ResourceType() ResourceType
ResourceType get resource type
func (*Resource) SchemaName ¶ added in v0.4.1
SchemaName get resource schema name
func (*Resource) SetComment ¶ added in v0.4.1
SetComment set resource comment
func (*Resource) SetIsTempResource ¶ added in v0.4.1
SetIsTempResource set whether resource is temp resource
func (*Resource) SetResourceType ¶ added in v0.4.1
func (r *Resource) SetResourceType(resourceType ResourceType)
SetResourceType set resource type
type ResourceType ¶ added in v0.4.1
type ResourceType string
ResourceType is resource type
const ( // ResourceTypeFile is file resource type ResourceTypeFile ResourceType = "file" // ResourceTypeJar is jar resource type ResourceTypeJar ResourceType = "jar" // ResourceTypeArchive is archive resource type, support .zip/.tgz/.tar.gz/.tar/.jar ResourceTypeArchive ResourceType = "archive" // ResourceTypePy is py resource type ResourceTypePy ResourceType = "py" // ResourceTypeTable is table resource type ResourceTypeTable ResourceType = "table" // ResourceTypeVolumeFile is volume_file resource type ResourceTypeVolumeFile ResourceType = "volume_file" // ResourceTypeVolumeArchive is volume_archive resource type ResourceTypeVolumeArchive ResourceType = "volume_archive" // ResourceTypeUnknown is unknown resource type ResourceTypeUnknown ResourceType = "unknown" )
func ResourceTypeFromStr ¶ added in v0.4.1
func ResourceTypeFromStr(str string) ResourceType
ResourceTypeFromStr convert string to ResourceType
type Resources ¶ added in v0.4.1
type Resources struct { ProjectName string OdpsIns *Odps ChunkSize int // contains filtered or unexported fields }
Resources is a collection of resources
func NewResources ¶ added in v0.4.1
NewResources create a new Resources
func (*Resources) CreateFileResource ¶ added in v0.4.1
func (r *Resources) CreateFileResource(projectName, schemaName string, lfr ReaderResource, overwrite bool) error
CreateFileResource create a file resource
func (*Resources) CreateTableResource ¶ added in v0.4.1
func (r *Resources) CreateTableResource(projectName, schemaName string, tr TableResource, overwrite bool) error
CreateTableResource create a table resource
func (*Resources) UpdateFileResource ¶ added in v0.4.1
func (r *Resources) UpdateFileResource(projectName, schemaName string, lfr ReaderResource) error
UpdateFileResource update a file resource
type SQLCostTask ¶
func NewSQLCostTask ¶
func NewSQLCostTask(name string, query string, hints map[string]string) SQLCostTask
func (*SQLCostTask) TaskType ¶
func (t *SQLCostTask) TaskType() string
type SQLPlanTask ¶
func (*SQLPlanTask) TaskType ¶
func (t *SQLPlanTask) TaskType() string
type SQLTask ¶
type SQLTask struct { XMLName xml.Name `xml:"SQL"` TaskName `xml:"Name"` TaskConfig Query string }
func NewSQLTaskWithOptions ¶ added in v0.4.1
func NewSQLTaskWithOptions(query string, option *options.SQLTaskOptions) SQLTask
NewSQLTaskWithOptions Create a SQLTask with options.SQLTaskOptions
func (*SQLTask) GetSelectResultAsCsv ¶
GetSelectResultAsCsv 最多返回1W条数据
type Schema ¶ added in v0.3.8
type Schema struct {
// contains filtered or unexported fields
}
Schema represent the namespace schema in odps projects
func (*Schema) ChangeComment ¶ added in v0.4.1
ChangeComment Modify the comment content of the schema.
func (*Schema) ChangeOwner ¶ added in v0.4.1
ChangeOwner Only the Project Owner or users with the Super_Administrator role can execute commands that modify the schema Owner.
func (*Schema) CreateTime ¶ added in v0.3.8
CreateTime return the schema create time
func (*Schema) ModifiedTime ¶ added in v0.3.8
ModifiedTime return the schema modified time
func (*Schema) ProjectName ¶ added in v0.3.8
ProjectName return the project name
func (*Schema) ResourceUrl ¶ added in v0.3.8
type Schemas ¶ added in v0.3.8
type Schemas struct {
// contains filtered or unexported fields
}
func NewSchemas ¶ added in v0.3.8
NewSchemas if projectName is not set,the default projectName of odps will be used
type TFilterFunc ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represent the table in odps projects
func (*Table) AddColumns ¶ added in v0.3.14
func (t *Table) AddColumns(columns []tableschema.Column, ifNotExists bool) error
func (*Table) AddPartition ¶
AddPartition Example: AddPartition(true, "region=10026/name=abc")
Example ¶
table := odpsIns.Table("sale_detail") err := table.AddPartition(true, "sale_date=202111/region=hangzhou") if err != nil { log.Fatalf("%+v", err) }
Output:
func (*Table) AddPartitions ¶ added in v0.3.8
AddPartitions Example: AddPartitions(true, []string{"region=10026/name=abc", "region=10027/name=mhn"})
func (*Table) AlterColumnType ¶ added in v0.3.14
func (*Table) ChangeClusterInfo ¶ added in v0.3.14
func (t *Table) ChangeClusterInfo(clusterInfo tableschema.ClusterInfo) error
func (*Table) ChangeColumnName ¶ added in v0.3.14
func (*Table) ChangeComment ¶ added in v0.3.14
ChangeComment Modify the comment content of the table.
func (*Table) ChangeOwner ¶ added in v0.3.14
ChangeOwner Only the Project Owner or users with the Super_Administrator role can execute commands that modify the table Owner.
func (*Table) ClusterInfo ¶ added in v0.4.0
func (t *Table) ClusterInfo() tableschema.ClusterInfo
ClusterInfo Returns the cluster info of the table
func (*Table) ColumnMaskInfos ¶ added in v0.3.17
func (t *Table) ColumnMaskInfos() ([]ColumnMaskInfo, error)
ColumnMaskInfos Returns the column level data policy of the table
func (*Table) CreatedTime ¶
func (*Table) CryptoAlgo ¶
func (*Table) DeletePartition ¶
DeletePartition Example: DeletePartition(true, "region=10026/name=abc")
func (*Table) DeletePartitions ¶ added in v0.3.8
DeletePartitions Example: DeletePartitions(true, []string{"region=10026/name=abc", "region=10027/name=mhn"})
func (*Table) DropColumns ¶ added in v0.3.14
func (*Table) ExecSql ¶
Example ¶
// table := odps.NewTable(odpsIns, "go_sdk_regression_testing", "sale_detail") table := odpsIns.Table("has_struct") // instance, err := table.ExecSql("SelectSale_detail", "select * from sale_detail;") instance, err := table.ExecSql("Select_has_struct", "select * from has_struct;") if err != nil { log.Fatalf("%+v", err) } err = instance.WaitForSuccess() if err != nil { log.Fatalf("%+v", err) } results, err := instance.GetResult() if err != nil { log.Fatalf("%+v", err) } else if len(results) == 0 { log.Fatalf("should get at least one result") } println(fmt.Sprintf("%+v", results[0].Result))
Output:
func (*Table) ExecSqlWithHints ¶
func (*Table) GetPartition ¶ added in v0.3.8
GetPartition get partitions with partitionKey like "region=10026/name=abc", error if not found
func (*Table) GetPartitionValues ¶ added in v0.3.8
func (*Table) GetPartitions ¶
GetPartitions get partitions
Example ¶
table := odpsIns.Table("sale_detail") partitions, err := table.GetPartitions() if err != nil { log.Fatalf("%+v", err) } for _, p := range partitions { println(fmt.Sprintf("Value: %s", p.Value())) println(fmt.Sprintf("Create time: %s", p.CreatedTime())) println(fmt.Sprintf("Last DDL time: %s", p.LastDDLTime())) println(fmt.Sprintf("Last Modified time: %s", p.LastModifiedTime())) println("") }
Output:
func (*Table) HubLifeCycle ¶
func (*Table) IsLoadedExtended ¶ added in v0.3.10
func (*Table) LastDDLTime ¶
func (*Table) LastModifiedTime ¶
func (*Table) Load ¶
Example ¶
table := odpsIns.Table("has_struct") err := table.Load() if err != nil { log.Fatalf("%+v", err) } schema := table.Schema() println(fmt.Sprintf("%+v", schema.Columns))
Output:
func (*Table) LoadExtendedInfo ¶
func (*Table) MaxExtendedLabel ¶
func (*Table) MaxLabel ¶
MaxLabel 获取最高的label级别 Label的定义分两部分: 1. 业务分类:C,S,B 2. 数据等级:1,2,3,4
二者是正交关系,即C1,C2,C3,C4,S1,S2,S3,S4,B1,B2,B3,B4。
MaxLabel的语意: 1. MaxLabel=max(TableLabel, ColumnLabel), max(...)函数的语意由Label中的数据等级决定:4>3>2>1 2. MaxLabel显示: 当最高等级Label只出现一次时,MaxLabel=业务分类+数据等级,例如:B4, C3,S2 当最高等级LabeL出现多次,但业务分类也唯一,MaxLabel=业务分类+数据等级,例如:B4, C3,S2 当最高等级Label出现多次,且业务不唯一,MaxLabel=L+数据等级,例如:L4, L3
func (*Table) PartitionColumns ¶
func (t *Table) PartitionColumns() []tableschema.Column
func (*Table) PrimaryKeys ¶ added in v0.4.0
PrimaryKeys Returns the primary keys of the table
func (*Table) ProjectName ¶
func (*Table) ResourceUrl ¶
func (*Table) Schema ¶
func (t *Table) Schema() tableschema.TableSchema
func (*Table) SchemaJson ¶
func (*Table) SchemaName ¶ added in v0.3.8
func (*Table) SetLifeCycle ¶ added in v0.3.16
SetLifeCycle Modify the life cycle of an existing partitioned table or non-partitioned table.
func (*Table) ShardInfoJson ¶
func (*Table) TableExtendedLabels ¶
func (*Table) TableLabel ¶
func (*Table) Touch ¶ added in v0.3.14
Touch can modify the LastModifiedTime of the table, make LastModifiedTime change to the current time
func (*Table) Transactional ¶ added in v0.4.0
Transactional Returns whether the table is Transaction Table or Delta Table
type TableOrErr ¶
TableOrErr is used for the return value of Tables.List
type TableResource ¶ added in v0.4.1
type TableResource struct {
Resource
}
TableResource is a table resource
func NewTableResource ¶ added in v0.4.1
func NewTableResource(projectName, tableName string, partition string) TableResource
NewTableResource create a new TableResource
type TableType ¶
type TableType int
func TableTypeFromStr ¶
func (TableType) MarshalXML ¶
func (*TableType) UnmarshalXML ¶
type Tables ¶
type Tables struct {
// contains filtered or unexported fields
}
Tables used for get all the tables in an odps project
func (*Tables) BatchLoadTables ¶
BatchLoadTables can get at most 100 tables, and the information of table is according to the permission
Example ¶
tablesIns := odps.NewTables(odpsIns, "", "") tableNames := []string{ "has_struct", "sale_detail", "testtable", "user", } tables, err := tablesIns.BatchLoadTables(tableNames) if err != nil { log.Fatalf("%+v", err) } for _, table := range tables { println(fmt.Sprintf("%s, %s, %s", table.Name(), table.TableID(), table.Type())) } schema := tables[len(tables)-1].Schema() for _, c := range schema.Columns { println(fmt.Sprintf("%s, %s, %t, %s", c.Name, c.Type, c.NotNull, c.Comment)) }
Output:
func (*Tables) Create ¶
func (ts *Tables) Create( schema tableschema.TableSchema, createIfNotExists bool, hints, alias map[string]string, ) error
Create table with schema, the schema can be build with tableschema.SchemaBuilder parameter hints can affect the `Set` sql execution, like odps.mapred.map.split.size you can get introduce about alias from the reference of alias command
Example ¶
c1 := tableschema.Column{ Name: "name", Type: datatype.StringType, Comment: "name of user", } c2 := tableschema.Column{ Name: "age", Type: datatype.IntType, Comment: "how old is the user", } p1 := tableschema.Column{ Name: "region", Type: datatype.StringType, Comment: "居住区域", } p2 := tableschema.Column{ Name: "code", Type: datatype.IntType, } hints := make(map[string]string) hints["odps.sql.preparse.odps"] = "lot" hints["odps.sql.planner.mode"] = "lot" hints["odps.sql.planner.parser.odps"] = "true" hints["odps.sql.ddl.odps"] = "true" hints["odps.compiler.output.format"] = "lot,pot" hints["odps.namespace.schema"] = "false" builder := tableschema.NewSchemaBuilder() builder.Name("user_temp"). Comment("这就是一条注释"). Columns(c1, c2). PartitionColumns(p1, p2). Lifecycle(2) schema := builder.Build() sql, _ := schema.ToSQLString(defaultProjectName, "", false) println(sql) tables := odps.NewTables(odpsIns, odpsIns.DefaultProjectName(), "") err := tables.Create(schema, true, hints, nil) if err != nil { log.Fatalf("%+v", err) }
Output:
func (*Tables) CreateExternal ¶
func (ts *Tables) CreateExternal( schema tableschema.TableSchema, createIfNotExists bool, serdeProperties map[string]string, jars []string, hints, alias map[string]string, ) error
CreateExternal create external table, the schema can be build with tableschema.SchemaBuilder
func (*Tables) CreateView ¶ added in v0.3.14
func (ts *Tables) CreateView(schema tableschema.TableSchema, orReplace, createIfNotExists, buildDeferred bool, ) error
func (*Tables) CreateWithDataHub ¶
func (ts *Tables) CreateWithDataHub( schema tableschema.TableSchema, createIfNotExists bool, shardNum, hubLifecycle int, ) error
func (*Tables) Delete ¶
Delete delete table
Example ¶
tables := odps.NewTables(odpsIns, odpsIns.DefaultProjectName(), "") err := tables.Delete("user_temp", false) if err != nil { log.Fatalf("%+v", err) }
Output:
func (*Tables) List ¶
func (ts *Tables) List(f func(*Table, error), filters ...TFilterFunc)
List get all the tables, filters can be specified with TableFilter.NamePrefix, TableFilter.Extended, TableFilter.Owner
Example ¶
ts := odps.NewTables(odpsIns, "", "") f := func(t *odps.Table, err error) { if err != nil { log.Fatalf("%+v", err) } println(fmt.Sprintf("%s, %s, %s", t.Name(), t.Owner(), t.Type())) } ts.List(f, odps.TableFilter.Extended())
Output:
type TaskConfig ¶
TaskConfig 作为embedding filed使用时,使用者自动实现Task接口的AddProperty方法
func (*TaskConfig) AddProperty ¶
func (t *TaskConfig) AddProperty(key, value string)
type TaskInInstance ¶
type TaskInInstance struct { Type string `xml:"Type,attr"` Name string StartTime common.GMTTime EndTime common.GMTTime `xml:"EndTime"` Status TaskStatus }
TaskInInstance 通过Instance创建的Task
type TaskProgressStage ¶
type TaskResult ¶
type TaskResult struct { Type string `xml:"Type,attr"` Name string Status TaskStatus Result struct { TransForm string `xml:"Transform,attr"` Format string `xml:"Format,attr"` // 这个字段没有用到 Content string `xml:",cdata"` } `xml:"Result"` }
func (*TaskResult) Content ¶ added in v0.0.5
func (tr *TaskResult) Content() string
type TaskStatus ¶
type TaskStatus int
func TaskStatusFromStr ¶
func TaskStatusFromStr(s string) TaskStatus
func (*TaskStatus) MarshalXML ¶
func (status *TaskStatus) MarshalXML(d *xml.Encoder, start xml.StartElement) error
func (TaskStatus) String ¶
func (status TaskStatus) String() string
func (*TaskStatus) UnmarshalXML ¶
func (status *TaskStatus) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type TaskSummary ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package options provides a set of configuration options to customize the behavior of the SDK.
|
Package options provides a set of configuration options to customize the behavior of the SDK. |