Giter VIP home page Giter VIP logo

Comments (8)

henrywu2019 avatar henrywu2019 commented on June 30, 2024

Thanks @rtfpessoa for the great question. There is an example for querying time/date data with Athena: https://github.com/uber/athenadriver/blob/master/examples/query/dml_select_time.go

Can you post one sample data stored in created_at column in your database/table? My initial guess would be the format is not compatible with any of these supported by Athena:

"date", "time", "time with time zone", "timestamp", "timestamp with time zone"

Hope this can help.

from athenadriver.

rtfpessoa avatar rtfpessoa commented on June 30, 2024

Hi @henrywoo thanks for the help.
That makes sense since the date is in RFC3339 (e.g.: 2021-01-01T12:12:12Z)

But, this also happens to int64, is it unrelated? What can be the reason?

from athenadriver.

rtfpessoa avatar rtfpessoa commented on June 30, 2024

Hi again @henrywoo,
Thanks to your tip about the format of the dates I was able to get most things working.
I think now the issue is with nillable values. Do you have any idea?

Seems like any value that comes null from the database will be read as an empty string instead of nil.

from athenadriver.

henrywu2019 avatar henrywu2019 commented on June 30, 2024

Hi @rtfpessoa Great to hear that the date issue is resolved.

For missing value handling, please refer to: https://github.com/uber/athenadriver#missing-value-handling

By default, we use empty string to replace missing values and empty string is preferred to default data.

from athenadriver.

rtfpessoa avatar rtfpessoa commented on June 30, 2024

Thanks a lot for your help.
Now it makes sense, I think at some point I noticed the SetMissingAsEmptyString but probably got the error of not setting the SetMissingAsDefault to true and did not think I was going the right way.

It almost works now but I have fields that are nillable like *time.Time or even *int64 and I never get nil even if the value is not returned from the database.

If you write var myTime *time.Time in go code the default value will be nil, and this was the same expectation I had for this library.
Can this be a bug? Or am I still missing some detail?

from athenadriver.

rtfpessoa avatar rtfpessoa commented on June 30, 2024

Hi @henrywoo did you got a chance to see my message? I was wondering if you did not because I forgot to mention you.

from athenadriver.

henrywoo avatar henrywoo commented on June 30, 2024

Can you share me some reproducible code? It is hard for me to reproduce the issue you described.

from athenadriver.

rtfpessoa avatar rtfpessoa commented on June 30, 2024

Hi @henrywoo,
Unfortunately we are not using athena anymore due to some challenges we found.
But maybe this can help other people so I am going to try to leave here what we were using:

Instantiating the client

func NewAthenaStore(config AthenaStoreConfiguration) AthenaStore {
	conf := drv.NewNoOpsConfig()
	conf.SetDB(config.GlueDatabaseName)
	conf.SetRegion(config.OutputBucketRegion)
	// Even though the workgroup already contains this configuration,
	// it is necessary to add it here, otherwise the client fails to be instantiated.
	conf.SetOutputBucket("s3://" + config.OutputBucketName)
	workgroup := drv.NewWG(config.AthenaWorkgroupName, nil, nil)
	conf.SetWorkGroup(workgroup)
	conf.SetWGRemoteCreationAllowed(false)
	db, _ := sql.Open(drv.DriverName, conf.Stringify())
}

Query struct

type PullRequestMetrics struct {
	ClosedAt                    *time.Time  `db:"closed_at"`
	NumberOfCommits  *int64          `db:"number_of_commits"`
}

Query

SELECT
	closed_at AS closed_at,
	commits AS number_of_commits
FROM
        pull_request

The json in s3 queries by athena sometimes has a closed_at and/or number_of_commits and sometimes does not.
The deserialization fails if the values are not present in the json. With the error I pasted before.

from athenadriver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.