cmd

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HistoryCmd = &cobra.Command{
	Use:   "history",
	Short: "export Athena execution history",
	Run: func(cmd *cobra.Command, args []string) {

		h, err := lib.ListHistory(historyCmdMaxResults, historyCmdWorkgroup)

		if err != nil {
			log.Fatal(err)
		}

		err = lib.RenderHistoryResults(h, q.Format)

		if err != nil {
			log.Fatal(err)
		}
	},
}

HistoryCmd ...

View Source
var PartitionCmd = &cobra.Command{
	Use:   "partition",
	Short: "add partitions to a table",
	Long: `Add partitions to a table by specifing an S3 location template and the various partitions for each template value. 
If included in your template Year, Month, and Day partitions will be added for each applicable date in the past.

	athena partition \
	  --database default \
	  --table cloudtrail \
	  --location-template "s3://mycloudtrailbucket/AWSLogs/{{.Account}}/CloudTrail/{{.Region}}/{{.Year}}/{{.Month}}/{{.Day}}" \
	  --partition Account=000000000,1111111111 \
	  --partition Region=us-east-1,us-west-2
    
	# Would add the following partitions to the default.cloudtrail table:
	# 
	# s3://mycloudtrailbucket/AWSLogs/000000000/CloudTrail/us-east-1/2020/09/29
	# s3://mycloudtrailbucket/AWSLogs/000000000/CloudTrail/us-east-1/2020/09/30
	# s3://mycloudtrailbucket/AWSLogs/000000000/CloudTrail/us-west-2/2020/09/29
	# s3://mycloudtrailbucket/AWSLogs/000000000/CloudTrail/us-west-2/2020/09/30
	# s3://mycloudtrailbucket/AWSLogs/1111111111/CloudTrail/us-east-1/2020/09/29
	# s3://mycloudtrailbucket/AWSLogs/1111111111/CloudTrail/us-east-1/2020/09/30
	# s3://mycloudtrailbucket/AWSLogs/1111111111/CloudTrail/us-west-2/2020/09/29
	# s3://mycloudtrailbucket/AWSLogs/1111111111/CloudTrail/us-west-2/2020/09/30
`,
	Run: func(cmd *cobra.Command, args []string) {
		lib.Partition(daysback, databaseName, tableName, locationTemplate, partitions)
	},
}

PartitionCmd ..

View Source
var QueryCmd = &cobra.Command{
	Use:   "query",
	Short: "query Athena",
	Run: func(cmd *cobra.Command, args []string) {
		_, err := lib.ParseFormat(q.Format)
		if err != nil {
			log.Fatal(err)
		}
		if q.QueryResultsBucket == outputBucketDefault {
			q.QueryResultsBucket = fmt.Sprintf("aws-athena-query-results-%s-%s", lib.AccountID(), lib.Region())
		}

		file, err := q.Execute()
		if err != nil {
			log.Fatal(err)
		}

		if file == nil {
			return
		}

		defer lib.CleanCache(file.Name())

		err = q.RenderQueryResults(file)

		if err != nil {
			log.Fatal(err)
		}
	},
}

QueryCmd ...

Functions

func Import

func Import(rootCmd *cobra.Command)

Import is used to import all of these package's commands

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL