nebula-contrib / nebula-jdbc

The JDBC connector for Nebula Graph.
41 stars 15 forks source link

Cannot query "show tags" #42

Closed cdalexndr closed 1 year ago

cdalexndr commented 1 year ago

Trying to query:

try (Connection connection = dataSource.getConnection()) {
     Statement statement = connection.createStatement();
     ResultSet res = statement.executeQuery( "show tags" );
 }

results in error: java.sql.SQLException: Method executeQuery() can only execute nGql to query data, but the current nGql do not contains any query keyword in [match, lookup, go, fetch, find, subgraph], please modify your nGql or use executeUpdate(), execute().

"execute()" and "executeUpdate()" don't return query results

Similar for other show/describe statements

cdalexndr commented 1 year ago

Found a test code snippet to call admin statements:

        String adminNGQL = "show hosts";
        boolean result = statement.execute(adminNGQL);
        assertTrue(result);

        ResultSet resultSet = statement.getResultSet();
        assertNotNull(resultSet);

I think show/describe statements should be allowed to run using statement.executeQuery in order to be compatible with higher level libraries, such as Spring data that calls executeQuery when expecting results. For example: JdbcOperations.queryForList("show tags", String.class)

wey-gu commented 1 year ago

@Nicole00 what do you think? It seems to restrict Nebula-JDBC on the above DQL-only queries isn't reasonable.