Skip to content

Commit

Permalink
Merge branch 'master' into cat-glob
Browse files Browse the repository at this point in the history
  • Loading branch information
tarikozyurtt authored Jul 10, 2024
2 parents 7d1c04e + 21fa2da commit d9c2594
Showing 1 changed file with 109 additions and 10 deletions.
119 changes: 109 additions & 10 deletions e2e/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestSelectCommand(t *testing.T) {
expectedValue: "id0\n",
},
{
name: "input:json-lines,output:csv,compression:gzip,select:with-where",
name: "input:json-lines,output:csv,select:with-where",
cmd: []string{
"select", "json",
"--output-format", "csv",
Expand Down Expand Up @@ -200,11 +200,11 @@ func TestSelectCommand(t *testing.T) {
},
informat: "json",
structure: "document",
outformat: "json",
outformat: "csv",
expectedValue: "id0\n",
},
{
name: "input:json-document,output:json,compression:gzip,select:with-document-access",
name: "input:json-document,output:csv,compression:gzip,select:with-document-access",
cmd: []string{
"select", "json",
"--structure", "document",
Expand All @@ -215,7 +215,7 @@ func TestSelectCommand(t *testing.T) {
informat: "json",
compression: true,
structure: "document",
outformat: "json",
outformat: "csv",
expectedValue: "id0\n",
},
{
Expand All @@ -233,7 +233,18 @@ func TestSelectCommand(t *testing.T) {
},
"csv": {
{
name: "input:csv,output:csv,delimiter:comma",
name: "input:csv,output:json,delimiter:comma",
cmd: []string{
"select", "csv",
"--output-format", "json",
"--query", query,
},
informat: "csv",
structure: ",",
outformat: "json",
},
{
name: "input:csv,output:csv,delimiter:comma,extra-flag:false",
cmd: []string{
"select", "csv",
"--query", query,
Expand All @@ -243,7 +254,7 @@ func TestSelectCommand(t *testing.T) {
outformat: "csv",
},
{
name: "input:csv,output:csv,delimiter:comma,compression:gzip",
name: "input:csv,output:csv,delimiter:comma,compression:gzip,extra-flag:false",
cmd: []string{
"select", "csv",
"--compression", "gzip",
Expand All @@ -254,6 +265,19 @@ func TestSelectCommand(t *testing.T) {
structure: ",",
outformat: "csv",
},
{
name: "input:csv,output:json,delimiter:comma,compression:gzip",
cmd: []string{
"select", "csv",
"--compression", "gzip",
"--output-format", "json",
"--query", query,
},
informat: "csv",
compression: true,
structure: ",",
outformat: "json",
},
{
name: "input:csv,output:csv,delimiter:comma,compression:gzip",
cmd: []string{
Expand All @@ -279,7 +303,7 @@ func TestSelectCommand(t *testing.T) {
outformat: "csv",
},
{
name: "input:csv,output:csv,delimiter:tab",
name: "input:csv,output:csv,delimiter:tab,extra-flag:false",
cmd: []string{
"select", "csv",
"--delimiter", "\t",
Expand All @@ -289,6 +313,18 @@ func TestSelectCommand(t *testing.T) {
structure: "\t",
outformat: "csv",
},
{
name: "input:csv,output:json,delimiter:tab",
cmd: []string{
"select", "csv",
"--delimiter", "\t",
"--output-format", "json",
"--query", query,
},
informat: "csv",
structure: "\t",
outformat: "json",
},
{
name: "input:csv,output:csv,delimiter:tab",
cmd: []string{
Expand Down Expand Up @@ -384,7 +420,7 @@ func TestSelectCommand(t *testing.T) {
informat: "csv",
compression: true,
structure: ",",
outformat: "csv",
outformat: "json",
expectedValue: "{\"id\":\"id0\"}\n",
},
{
Expand All @@ -398,7 +434,7 @@ func TestSelectCommand(t *testing.T) {
},
informat: "csv",
structure: "\t",
outformat: "csv",
outformat: "json",
expectedValue: "{\"id\":\"id0\"}\n",
},
{
Expand All @@ -414,7 +450,7 @@ func TestSelectCommand(t *testing.T) {
informat: "csv",
compression: true,
structure: "\t",
outformat: "csv",
outformat: "json",
expectedValue: "{\"id\":\"id0\"}\n",
},
},
Expand Down Expand Up @@ -483,6 +519,7 @@ func TestSelectCommand(t *testing.T) {

s3client, s5cmd := setup(t, withEndpointURL(endpoint), withRegion(region), withAccessKeyID(accessKeyID), withSecretKey(secretKey))
createBucket(t, s3client, bucket)

putFile(t, s3client, bucket, filename, contents)

tc.cmd = append(tc.cmd, src)
Expand All @@ -498,6 +535,68 @@ func TestSelectCommand(t *testing.T) {
}
}

func TestSelectCommandEmptyBucket(t *testing.T) {
t.Parallel()

const (
region = "us-east-1"
accessKeyID = "minioadmin"
secretKey = "minioadmin"

query = "SELECT * FROM s3object s"
)

endpoint := os.Getenv(s5cmdTestEndpointEnv)
if endpoint == "" {
t.Skipf("skipping the test because %v environment variable is empty", s5cmdTestEndpointEnv)
}

type testcase struct {
name string
cmd []string
}

testcases := []testcase{
{
name: "input:json-lines,output:json,all-versions:true,empty-bucket:true",
cmd: []string{
"select", "json",
"--all-versions",
"--query", query,
},
},
{
name: "input:csv,output:csv,delimiter:comma,all-versions:true,empty-bucket:true",
cmd: []string{
"select", "csv",
"--all-versions",
"--query", query,
},
},
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

bucket := s3BucketFromTestName(t)

s3client, s5cmd := setup(t, withEndpointURL(endpoint), withRegion(region), withAccessKeyID(accessKeyID), withSecretKey(secretKey))
createBucket(t, s3client, bucket)

src := fmt.Sprintf("s3://%s/", bucket)
tc.cmd = append(tc.cmd, src)
cmd := s5cmd(tc.cmd...)

result := icmd.RunCmd(cmd, withEnv("AWS_ACCESS_KEY_ID", accessKeyID), withEnv("AWS_SECRET_ACCESS_KEY", secretKey))

result.Assert(t, icmd.Success)
assert.DeepEqual(t, "", result.Stdout())
})
}
}

func TestSelectWithParquet(t *testing.T) {
// NOTE(deniz): We are skipping this test until the image we use in the
// service container releases parquet support for select api.
Expand Down

0 comments on commit d9c2594

Please sign in to comment.