>From Ali Alsuliman <[email protected]>: Ali Alsuliman has submitted this change. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17405 )
Change subject: [ASTERIXDB-3122][FUN] escape string values in DUMP_INDEX ...................................................................... [ASTERIXDB-3122][FUN] escape string values in DUMP_INDEX - user model changes: no - storage format changes: no - interface changes: no Change-Id: I9127d2346541f2cb2bc9d64016f4608ec4ec695c Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17405 Integration-Tests: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Reviewed-by: Ali Alsuliman <[email protected]> Reviewed-by: Murtadha Hubail <[email protected]> --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexReader.java M asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/dump_index/dump_index.2.update.sqlpp M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexDatasource.java M asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/GenericAdapterFactory.java M asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/FunctionDataSource.java M asterixdb/asterix-app/src/test/resources/runtimets/results/misc/dump_index/dump_index.10.adm 6 files changed, 49 insertions(+), 12 deletions(-) Approvals: Murtadha Hubail: Looks good to me, approved Ali Alsuliman: Looks good to me, but someone else must approve Jenkins: Verified; Verified Anon. E. Moose #1000171: diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexDatasource.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexDatasource.java index 3351075..691be47 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexDatasource.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexDatasource.java @@ -19,6 +19,8 @@ package org.apache.asterix.app.function; import org.apache.asterix.common.cluster.IClusterStateManager; +import org.apache.asterix.external.api.IDataParserFactory; +import org.apache.asterix.external.parser.factory.JSONDataParserFactory; import org.apache.asterix.metadata.api.IDatasourceFunction; import org.apache.asterix.metadata.declared.DataSourceId; import org.apache.asterix.metadata.declared.FunctionDataSource; @@ -59,4 +61,9 @@ AlgebricksAbsolutePartitionConstraint locations) { return new DumpIndexFunction(locations, indexDataflowHelperFactory, recDesc, comparatorFactories); } + + @Override + protected IDataParserFactory createDataParserFactory() { + return new JSONDataParserFactory(); + } } diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexReader.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexReader.java index e60b015..8ef094e 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexReader.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/function/DumpIndexReader.java @@ -25,6 +25,7 @@ import org.apache.asterix.external.api.IRawRecord; import org.apache.asterix.external.input.record.CharArrayRecord; import org.apache.asterix.om.base.ARecord; +import org.apache.asterix.om.base.AString; import org.apache.asterix.om.base.IACollection; import org.apache.asterix.om.base.IACursor; import org.apache.asterix.om.base.IAObject; @@ -132,6 +133,9 @@ case DATETIME: JSONUtil.quoteAndEscape(recordBuilder, field.toString()); break; + case STRING: + JSONUtil.quoteAndEscape(recordBuilder, ((AString) field).getStringValue()); + break; case MISSING: break; default: diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/dump_index/dump_index.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/dump_index/dump_index.2.update.sqlpp index 10378f2..3469c9a 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/dump_index/dump_index.2.update.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/dump_index/dump_index.2.update.sqlpp @@ -18,5 +18,6 @@ */ USE test; INSERT INTO ds ([{"id":1, "name": "name1"}, {"id":2, "name": "name2"}]); -UPSERT INTO ds2 ([{"id": 1,"age":30, "a1": {"b": [{"x": [1,2]}, {"x": [1,2]}]}, "a2": [{"x": [1,2]}, {"x": [1,2]}] }]); +UPSERT INTO ds2 ([{"id": 1,"age":"t\\'s", "a1": {"b": [{"x": [1,2]}, {"x": [1,2]}]}, "a2": [{"x": [1,2]}, {"x": [1,2]}] +}]); ANALYZE DATASET ds2; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/dump_index/dump_index.10.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/dump_index/dump_index.10.adm index a52ceae..d13e452 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/dump_index/dump_index.10.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/dump_index/dump_index.10.adm @@ -1 +1 @@ -[ { "values": [ 1, { "id": 1, "age": 30, "a1": { "b": [ { "x": [ 1, 2 ] }, { "x": [ 1, 2 ] } ] }, "a2": [ { "x": [ 1, 2 ] }, { "x": [ 1, 2 ] } ] } ] } ] \ No newline at end of file +[ { "values": [ 1, { "id": 1, "age": "t\\'s", "a1": { "b": [ { "x": [ 1, 2 ] }, { "x": [ 1, 2 ] } ] }, "a2": [ { "x": [ 1, 2 ] }, { "x": [ 1, 2 ] } ] } ] } ] \ No newline at end of file diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/GenericAdapterFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/GenericAdapterFactory.java index ac45f7a..8ec5af0 100644 --- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/GenericAdapterFactory.java +++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/GenericAdapterFactory.java @@ -37,7 +37,6 @@ import org.apache.asterix.external.dataset.adapter.FeedAdapter; import org.apache.asterix.external.dataset.adapter.GenericAdapter; import org.apache.asterix.external.indexing.ExternalFile; -import org.apache.asterix.external.parser.factory.ADMDataParserFactory; import org.apache.asterix.external.provider.DataflowControllerProvider; import org.apache.asterix.external.provider.DatasourceFactoryProvider; import org.apache.asterix.external.provider.ParserFactoryProvider; @@ -47,7 +46,6 @@ import org.apache.asterix.external.util.FeedLogManager; import org.apache.asterix.external.util.FeedUtils; import org.apache.asterix.om.types.ARecordType; -import org.apache.asterix.om.utils.RecordUtil; import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; import org.apache.hyracks.api.application.ICCServiceContext; @@ -209,18 +207,18 @@ } /** - * Use pre-configured datasource factory - * For function datasources + * Use pre-configured datasource factory For function datasources * * @param dataSourceFactory - * the function datasource factory + * the function datasource factory + * @param dataParserFactory + * the function data parser factory * @throws AlgebricksException */ - public void configure(IExternalDataSourceFactory dataSourceFactory) throws AlgebricksException { + public void configure(IExternalDataSourceFactory dataSourceFactory, IDataParserFactory dataParserFactory) + throws AlgebricksException { this.dataSourceFactory = dataSourceFactory; - dataParserFactory = new ADMDataParserFactory(); - dataParserFactory.setRecordType(RecordUtil.FULLY_OPEN_RECORD_TYPE); - dataParserFactory.configure(Collections.emptyMap()); + this.dataParserFactory = dataParserFactory; configuration = Collections.emptyMap(); } diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/FunctionDataSource.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/FunctionDataSource.java index a7d560c..5c874d7 100644 --- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/FunctionDataSource.java +++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/FunctionDataSource.java @@ -27,6 +27,8 @@ import org.apache.asterix.common.cluster.IClusterStateManager; import org.apache.asterix.common.functions.FunctionSignature; import org.apache.asterix.external.adapter.factory.GenericAdapterFactory; +import org.apache.asterix.external.api.IDataParserFactory; +import org.apache.asterix.external.parser.factory.ADMDataParserFactory; import org.apache.asterix.metadata.api.IDatasourceFunction; import org.apache.asterix.om.types.IAType; import org.apache.asterix.om.utils.RecordUtil; @@ -98,7 +100,10 @@ IClusterStateManager csm = metadataProvider.getApplicationContext().getClusterStateManager(); FunctionDataSourceFactory factory = new FunctionDataSourceFactory(createFunction(metadataProvider, getLocations(csm))); - adapterFactory.configure(factory); + IDataParserFactory dataParserFactory = createDataParserFactory(); + dataParserFactory.setRecordType(RecordUtil.FULLY_OPEN_RECORD_TYPE); + dataParserFactory.configure(Collections.emptyMap()); + adapterFactory.configure(factory, dataParserFactory); return metadataProvider.buildExternalDatasetDataScannerRuntime(jobSpec, itemType, adapterFactory, tupleFilterFactory, outputLimit); } @@ -112,6 +117,10 @@ return new AlgebricksAbsolutePartitionConstraint(ncs.toArray(new String[ncs.size()])); } + protected IDataParserFactory createDataParserFactory() { + return new ADMDataParserFactory(); + } + protected static DataSourceId createDataSourceId(FunctionIdentifier fid, String... parameters) { return new DataSourceId(FunctionSignature.getDataverseName(fid), fid.getName(), parameters); } -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17405 To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: neo Gerrit-Change-Id: I9127d2346541f2cb2bc9d64016f4608ec4ec695c Gerrit-Change-Number: 17405 Gerrit-PatchSet: 3 Gerrit-Owner: Ali Alsuliman <[email protected]> Gerrit-Reviewer: Ali Alsuliman <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Michael Blow <[email protected]> Gerrit-Reviewer: Murtadha Hubail <[email protected]> Gerrit-Reviewer: Till Westmann <[email protected]> Gerrit-MessageType: merged
