-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-27836 Fix documentation for QuerySqlTableFunction #12743
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
Merged
+93
−13
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
af7b745
IGNITE-27836 Fix documentation for QuerySqlTableFunction
zstan d93c03d
fix after review
zstan a4e0ef2
fix 11 jdk
zstan f36192d
fix
zstan f82b9fc
empty check
zstan 2be4401
fix after review
zstan 2041ee5
fix
zstan 88e2b12
fix
zstan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,9 @@ | |
| import java.util.concurrent.TimeUnit; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
| import org.apache.ignite.cache.query.annotations.QuerySqlTableFunction; | ||
| import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; | ||
| import org.apache.ignite.configuration.CacheConfiguration; | ||
| import org.apache.ignite.configuration.IgniteConfiguration; | ||
| import org.apache.ignite.configuration.SqlConfiguration; | ||
| import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; | ||
|
|
@@ -69,8 +71,14 @@ public class JdbcQueryTest extends GridCommonAbstractTest { | |
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { | ||
| CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>("TEST_CACHE_OWN") | ||
| .setSqlSchema("OWN_SCHEMA") | ||
| .setSqlFunctionClasses(FunctionsLibrary.class); | ||
|
|
||
| return super.getConfiguration(igniteInstanceName).setSqlConfiguration( | ||
| new SqlConfiguration().setQueryEnginesConfiguration(new CalciteQueryEngineConfiguration())); | ||
| new SqlConfiguration() | ||
| .setQueryEnginesConfiguration(new CalciteQueryEngineConfiguration())) | ||
| .setCacheConfiguration(ccfg); | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
|
|
@@ -113,6 +121,21 @@ private void connect(String url) throws Exception { | |
| stopAllGrids(); | ||
| } | ||
|
|
||
| /** Test user defined table through jdbc. */ | ||
| @Test | ||
| public void testUdt() throws Exception { | ||
| try (PreparedStatement ps = conn.prepareStatement("SELECT * FROM TABLE(\"OWN_SCHEMA\".STR_ARRAY_CONSUME_TABLE(?))")) { | ||
| ps.setObject(1, List.of("row1", "row2")); | ||
| ResultSet rs = ps.executeQuery(); | ||
|
|
||
| assertTrue(rs.next()); | ||
| assertEquals("row1", rs.getString(1)); | ||
|
|
||
| assertTrue(rs.next()); | ||
| assertEquals("row2", rs.getString(1)); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| /** | ||
| * @throws SQLException If failed. | ||
| */ | ||
|
|
@@ -490,4 +513,16 @@ public ObjectToStore(int id, String name, double val) { | |
| return Objects.hash(id, name, val); | ||
| } | ||
| } | ||
|
|
||
| /** User defined functions. */ | ||
| public static class FunctionsLibrary { | ||
| /** Function consume String array and output it row by row. */ | ||
| @QuerySqlTableFunction(alias = "STR_ARRAY_CONSUME_TABLE", columnTypes = {String.class}, columnNames = {"RESULT"}) | ||
| public static Iterable<Object[]> strArrConsumeTable(List<String> array) { | ||
| return array.stream() | ||
| .map(Object::toString) | ||
| .map(str -> new Object[]{str}) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.