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

JDBC DatabaseMetaData.getFunctionColumns error #1459

Closed
dbschema-pro opened this issue Jul 5, 2023 · 5 comments
Closed

JDBC DatabaseMetaData.getFunctionColumns error #1459

dbschema-pro opened this issue Jul 5, 2023 · 5 comments
Assignees
Labels

Comments

@dbschema-pro
Copy link

Calling 'SnowflakeDatabaseMetaData.getFunctionColumns' may throw an exception, even if the method gets the database and schema names as parameters.

net.snowflake.client.jdbc.SnowflakeSQLException: Cannot perform DESCRIBE. This session does not have a current schema. Call 'USE SCHEMA', or use a qualified name.
  at net.snowflake.client.jdbc.SnowflakeUtil.checkErrorAndThrowExceptionSub(SnowflakeUtil.java:127)
  at net.snowflake.client.jdbc.SnowflakeUtil.checkErrorAndThrowException(SnowflakeUtil.java:67)
  at net.snowflake.client.core.StmtUtil.pollForOutput(StmtUtil.java:456)
  at net.snowflake.client.core.StmtUtil.execute(StmtUtil.java:366)
  at net.snowflake.client.core.SFStatement.executeHelper(SFStatement.java:464)
  at net.snowflake.client.core.SFStatement.executeQueryInternal(SFStatement.java:192)
  at net.snowflake.client.core.SFStatement.executeQuery(SFStatement.java:129)
  at net.snowflake.client.core.SFStatement.execute(SFStatement.java:742)
  at net.snowflake.client.core.SFStatement.execute(SFStatement.java:652)
  at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQueryInternal(SnowflakeStatementV1.java:236)
  at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQuery(SnowflakeStatementV1.java:131)
  at net.snowflake.client.jdbc.SnowflakeDatabaseMetaData.executeAndReturnEmptyResultIfNotFound(SnowflakeDatabaseMetaData.java:3353)
  at net.snowflake.client.jdbc.SnowflakeDatabaseMetaData.getFunctionColumns(SnowflakeDatabaseMetaData.java:3199)
@sfc-gh-spanaite sfc-gh-spanaite self-assigned this Jul 12, 2023
@sfc-gh-igarish
Copy link
Collaborator

@sfc-gh-spanaite do you able to repro and make any progress?

@sfc-gh-spanaite
Copy link
Contributor

sfc-gh-spanaite commented Oct 18, 2023

@sfc-gh-igarish I am not able to reproduce this.

@wise-coders Can you provide a sample code that can reproduce the issue?
I used this sample:

Statement statement = con.createStatement();
statement.execute(
          "create or replace function FUNC111(a number, b number)\n"
              + "returns NUMBER comment='multiply numbers' as 'a*b'");

String database = con.getCatalog();
String schema = con.getSchema();

DatabaseMetaData metaData = con.getMetaData();

ResultSet res = metaData.getFunctionColumns(database, schema, "FUNC111", "%");
res.next();
System.out.println("Database" + "\t" + "Schema" + "\t" + "Function");
System.out.println(res.getString(1) + "\t" + res.getString(2) + "\t" + res.getString(3));

and I am getting back:

$ java -cp .:snowflake-jdbc-3.14.2.jar GithubIssue1459.java
Database	Schema	Function
SERGIU_TESTDB	PUBLIC	FUNC111

@dbschema-pro
Copy link
Author

We found out that this happens for build-in functions and procedures.

it seems that built in function (is_buildin = ‚Y‘) could not use „desc function“

But the build-in functions are listed by SELECT GET_DDL ( 'SCHEMA', '<schema_name>', true)
and DatabaseMetaData.getFunctions() and getProcedures().
I think you should exclude the build-in procedures and functions from this methods.

@sfc-gh-spanaite
Copy link
Contributor

This seems to be described as the same issue from 1510.

@sfc-gh-spanaite
Copy link
Contributor

I'll go ahead and close this one as well as 1510 has been closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants