-
Notifications
You must be signed in to change notification settings - Fork 12
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
Implement Select filter value auto-completion for SQL mode #3277
Merged
jnsrnhld
merged 8 commits into
develop
from
sql/feature/sql-filter-value-autocompletion
Jan 24, 2024
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c6e0ba6
Implement Select filter value auto-completion for SQL mode
jnsrnhld f113308
Revert test spec changes
jnsrnhld dd5d148
Revert formatting change
jnsrnhld 5114ac9
Use Streams for value auto-completion
jnsrnhld ca7cfa8
fix inline doc
jnsrnhld 91fc062
link classes properly
jnsrnhld 70b2f70
Fix SQL storage handler
jnsrnhld 44d5480
Update backend/src/main/java/com/bakdata/conquery/mode/local/SqlStora…
jnsrnhld 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 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 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 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 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 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
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/com/bakdata/conquery/mode/StorageHandler.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.bakdata.conquery.mode; | ||
|
||
import java.util.List; | ||
|
||
import com.bakdata.conquery.io.storage.NamespaceStorage; | ||
import com.bakdata.conquery.models.datasets.Column; | ||
|
||
public interface StorageHandler { | ||
|
||
List<String> lookupColumnValues(NamespaceStorage namespaceStorage, Column column); | ||
|
||
} |
This file contains 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
23 changes: 23 additions & 0 deletions
23
backend/src/main/java/com/bakdata/conquery/mode/cluster/ClusterStorageHandler.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.bakdata.conquery.mode.cluster; | ||
|
||
import java.util.List; | ||
|
||
import com.bakdata.conquery.io.storage.NamespaceStorage; | ||
import com.bakdata.conquery.mode.StorageHandler; | ||
import com.bakdata.conquery.models.datasets.Column; | ||
import com.bakdata.conquery.models.datasets.ImportColumn; | ||
import com.bakdata.conquery.models.events.stores.root.StringStore; | ||
|
||
public class ClusterStorageHandler implements StorageHandler { | ||
|
||
@Override | ||
public List<String> lookupColumnValues(NamespaceStorage namespaceStorage, Column column) { | ||
return namespaceStorage.getAllImports().stream() | ||
.filter(imp -> imp.getTable().equals(column.getTable())) | ||
.flatMap(imp -> { | ||
final ImportColumn importColumn = imp.getColumns()[column.getPosition()]; | ||
return ((StringStore) importColumn.getTypeDescription()).iterateValues(); | ||
}) | ||
.toList(); | ||
} | ||
} |
This file contains 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 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
44 changes: 44 additions & 0 deletions
44
backend/src/main/java/com/bakdata/conquery/mode/local/SqlStorageHandler.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.bakdata.conquery.mode.local; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import com.bakdata.conquery.io.storage.NamespaceStorage; | ||
import com.bakdata.conquery.mode.StorageHandler; | ||
import com.bakdata.conquery.models.datasets.Column; | ||
import com.bakdata.conquery.sql.execution.SqlExecutionService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.jooq.Record1; | ||
import org.jooq.Result; | ||
import org.jooq.Select; | ||
import org.jooq.impl.DSL; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class SqlStorageHandler implements StorageHandler { | ||
|
||
private final SqlExecutionService sqlExecutionService; | ||
|
||
@Override | ||
public List<String> lookupColumnValues(NamespaceStorage namespaceStorage, Column column) { | ||
Select<Record1<Object>> columValuesQuery = DSL.selectDistinct(DSL.field(DSL.name(column.getName()))) | ||
.from(DSL.table(DSL.name(column.getTable().getName()))); | ||
return queryForDistinctValues(columValuesQuery); | ||
} | ||
|
||
private List<String> queryForDistinctValues(Select<Record1<Object>> columValuesQuery) { | ||
Result<?> result = sqlExecutionService.execute(columValuesQuery); | ||
try { | ||
return result.getValues(0, String.class).stream() | ||
// the database might return null or an empty string as a distinct value | ||
.filter(value -> value != null && !value.isEmpty()) | ||
.toList(); | ||
} | ||
catch (Exception e) { | ||
log.error("Expecting exactly 1 column in Result when querying for distinct values of a column. Query: {}. Error: {}", columValuesQuery, e); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
} |
This file contains 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 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 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 |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
import com.bakdata.conquery.models.dictionary.Dictionary; | ||
import com.bakdata.conquery.models.dictionary.MapDictionary; | ||
import com.bakdata.conquery.models.events.MajorTypeId; | ||
import com.bakdata.conquery.models.events.stores.root.StringStore; | ||
import com.bakdata.conquery.models.identifiable.IdMutex; | ||
import com.bakdata.conquery.models.identifiable.Labeled; | ||
import com.bakdata.conquery.models.identifiable.ids.NamespacedIdentifiable; | ||
|
@@ -156,13 +155,8 @@ public TrieSearch<FrontendValue> createTrieSearch(IndexConfig config, NamespaceS | |
|
||
final TrieSearch<FrontendValue> search = new TrieSearch<>(suffixLength, config.getSearchSplitChars()); | ||
|
||
storage.getAllImports().stream() | ||
.filter(imp -> imp.getTable().equals(getTable())) | ||
.flatMap(imp -> { | ||
final ImportColumn importColumn = imp.getColumns()[getPosition()]; | ||
|
||
return ((StringStore) importColumn.getTypeDescription()).iterateValues(); | ||
}) | ||
storage.getStorageHandler() | ||
.lookupColumnValues(storage, this).stream() | ||
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. perfekt, du handlest das hier nur als stream weiter. Dann bitte auch als Stream ausgeben. Die haben potential riesig zu sein |
||
.map(value -> new FrontendValue(value, value)) | ||
.onClose(() -> log.debug("DONE processing values for {}", getId())) | ||
|
||
|
This file contains 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, das darf glaube ich keine Liste sein, die sind riesig. Kriegst du das mit Streams implementiert?