-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate dependency from async-query-core to legacy (#2786)
Signed-off-by: Tomoyuki Morita <[email protected]>
- Loading branch information
Showing
11 changed files
with
72 additions
and
66 deletions.
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
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
46 changes: 46 additions & 0 deletions
46
...main/java/org/opensearch/sql/spark/transport/format/CreateAsyncQueryRequestConverter.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,46 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.spark.transport.format; | ||
|
||
import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import org.opensearch.core.xcontent.XContentParser; | ||
import org.opensearch.sql.spark.rest.model.CreateAsyncQueryRequest; | ||
import org.opensearch.sql.spark.rest.model.LangType; | ||
|
||
@UtilityClass | ||
public class CreateAsyncQueryRequestConverter { | ||
public static CreateAsyncQueryRequest fromXContentParser(XContentParser parser) { | ||
String query = null; | ||
LangType lang = null; | ||
String datasource = null; | ||
String sessionId = null; | ||
try { | ||
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser); | ||
while (parser.nextToken() != XContentParser.Token.END_OBJECT) { | ||
String fieldName = parser.currentName(); | ||
parser.nextToken(); | ||
if (fieldName.equals("query")) { | ||
query = parser.textOrNull(); | ||
} else if (fieldName.equals("lang")) { | ||
String langString = parser.textOrNull(); | ||
lang = LangType.fromString(langString); | ||
} else if (fieldName.equals("datasource")) { | ||
datasource = parser.textOrNull(); | ||
} else if (fieldName.equals("sessionId")) { | ||
sessionId = parser.textOrNull(); | ||
} else { | ||
throw new IllegalArgumentException("Unknown field: " + fieldName); | ||
} | ||
} | ||
return new CreateAsyncQueryRequest(query, datasource, lang, sessionId); | ||
} catch (Exception e) { | ||
throw new IllegalArgumentException( | ||
String.format("Error while parsing the request body: %s", e.getMessage())); | ||
} | ||
} | ||
} |
7 changes: 6 additions & 1 deletion
7
...rk/asyncquery/model/AsyncQueryResult.java → ...ark/transport/model/AsyncQueryResult.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
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