uber/athenadriver

results bucket with folders add an empty folder at room

mrsufgi opened this issue · 3 comments

Let me first thank you for this amazing work, seems like you're deeply invested on this but tbh, it was really hard to find 🤔

I wanted to use my existing bucket but in a different folder, so I added a folder in the bucket and changed the URL to:

conf, _ := drv.NewDefaultConfig("s3://athenaplayground/local/",

it works, but when I went to S3 to check my bucket I noticed this minor bug:

image

I also tried creating local folder in my bucket first, but the results were in //local

<3

Thanks @mrsufgi for the great report.

Do you mean the minor bug is from S3 or athenadriver? Athenadriver/Athena doesn't create outputlocation folder automatically. (It does create sub-folders to store query results though.)

If you create local folder in your bucket first, the results should be inside the local folder. If not, could you please show me your code and screenshot so I can reproduce it? Thanks a lot.

I don't know where the bug originates but I can help u reproduce.

My bucket before running a query:
image

func Test_athenaTasksRepository_GetTaskDuration(t *testing.T) {
	os.Setenv("AWS_SDK_LOAD_CONFIG", "1")
	conf, _ := drv.NewDefaultConfig("s3://athenaplayground/local/", "us-west-2", "none", "none") // using IAM role!
	conn, err := sql.Open(drv.DriverName, conf.Stringify())
	if err != nil {
		log.Fatal(err)
	}

	ar := NewAthenaTasksRepository(conn)

	type args struct {
		id string
	}
	tests := []struct {
		name    string
		ar      domain.TasksRepository
		args    args
		want    int
		wantErr bool
	}{
		{"happy task", ar, args{id: "5eb00783a3f41400105a0e55"}, 1189, false},
	}
	for _, tt := range tests {
		tt := tt
		t.Run(tt.name, func(t *testing.T) {
			got, err := tt.ar.GetTaskDuration(tt.args.id)
			if (err != nil) != tt.wantErr {
				t.Errorf("athenaTasksRepository.GetTaskDuration() error = %v, wantErr %v", err, tt.wantErr)
				return
			}
			if got != tt.want {
				t.Errorf("athenaTasksRepository.GetTaskDuration() = %v, want %v", got, tt.want)
			}
		})
	}
}

after running the test (which runs simple SELECT query)
image

the local folder I created is empty, and the new empty name folder has a local folder with the results inside that folder.

Huge thanks to @mrsufgi