Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to host #144

Open
ezbercihk opened this issue Jul 19, 2023 · 5 comments
Open

Unable to connect to host #144

ezbercihk opened this issue Jul 19, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@ezbercihk
Copy link

With 1.3.1 upgrade, we start to get this error when we try to run SELECT queries and when downgraded to 1.3.0, this issue is no longer there. Below is the error we get back:

"error":"databricks: driver error: error initializing thrift client: databricks: missing Hostname"

@rcypher-databricks
Copy link
Contributor

I'm sorry you've encountered this issue. Could I get some more information about how you are connecting and running the query?

@rcypher-databricks
Copy link
Contributor

Looking at 1.3.1 the only thing that release added is a bug fix when handling query results. I'm not sure how it would affect creating a connection.

@ezbercihk
Copy link
Author

@rcypher-databricks apologies for the silence.. I will get you the details on how we connect shortly.. we also didn't change anything on our side but just upgraded to the new version, and it stopped working with this error. I will get back to you with more details.

@ezbercihk
Copy link
Author

@rcypher-databricks here's what our code that makes the connection looks like:

func initializeConnection(cfg *config.Config) (*sql.DB, error) {

	var endpointPath string
	if strings.Contains(cfg.Databricks.SQLEndpointId, "/") {
		endpointPath = fmt.Sprintf("/sql/protocolv1/o/%s", cfg.Databricks.SQLEndpointId)
	} else {
		endpointPath = fmt.Sprintf("/sql/1.0/endpoints/%s", cfg.Databricks.SQLEndpointId)
	}

	connector, err := dbsql.NewConnector(
		dbsql.WithServerHostname(cfg.Databricks.URL),
		dbsql.WithPort(443),
		dbsql.WithHTTPPath(endpointPath),
		dbsql.WithAccessToken(cfg.Databricks.PAT),
		dbsql.WithUserAgentEntry("Kobai Saturn"),
		dbsql.WithInitialNamespace(cfg.Databricks.CatalogName, cfg.Top.SchemaPrefix),
	)
	if err != nil {
		return nil, err
	}
	return sql.OpenDB(connector), nil
}

It think it is pretty standard, and like I said, nothing changed in our code. The only change was upgrading the package and we started getting that error.

@yunbodeng-db
Copy link
Contributor

@rcypher-databricks here's what our code that makes the connection looks like:

func initializeConnection(cfg *config.Config) (*sql.DB, error) {

	var endpointPath string
	if strings.Contains(cfg.Databricks.SQLEndpointId, "/") {
		endpointPath = fmt.Sprintf("/sql/protocolv1/o/%s", cfg.Databricks.SQLEndpointId)
	} else {
		endpointPath = fmt.Sprintf("/sql/1.0/endpoints/%s", cfg.Databricks.SQLEndpointId)
	}

	connector, err := dbsql.NewConnector(
		dbsql.WithServerHostname(cfg.Databricks.URL),
		dbsql.WithPort(443),
		dbsql.WithHTTPPath(endpointPath),
		dbsql.WithAccessToken(cfg.Databricks.PAT),
		dbsql.WithUserAgentEntry("Kobai Saturn"),
		dbsql.WithInitialNamespace(cfg.Databricks.CatalogName, cfg.Top.SchemaPrefix),
	)
	if err != nil {
		return nil, err
	}
	return sql.OpenDB(connector), nil
}

It think it is pretty standard, and like I said, nothing changed in our code. The only change was upgrading the package and we started getting that error.

What was your cfg looking like? The error message is pretty clear so we should check the input to the driver. Can you turn on the logging and check the logs?

@kravets-levko kravets-levko added the bug Something isn't working label Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants