Skip to content

Commit

Permalink
Rename cities dataset to flatten
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Feb 5, 2025
1 parent 5bb0617 commit bd8942d
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/user/dql/metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SQL query::
| docTestCluster | null | accounts | BASE TABLE | null | null | null | null | null | null |
| docTestCluster | null | apache | BASE TABLE | null | null | null | null | null | null |
| docTestCluster | null | books | BASE TABLE | null | null | null | null | null | null |
| docTestCluster | null | cities | BASE TABLE | null | null | null | null | null | null |
| docTestCluster | null | flatten | BASE TABLE | null | null | null | null | null | null |
| docTestCluster | null | json_test | BASE TABLE | null | null | null | null | null | null |
| docTestCluster | null | nested | BASE TABLE | null | null | null | null | null | null |
| docTestCluster | null | nyc_taxi | BASE TABLE | null | null | null | null | null | null |
Expand Down
6 changes: 3 additions & 3 deletions docs/user/ppl/cmd/flatten.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Example 1: Flatten an object field

PPL query::

os> source=cities | flatten location | fields name, country, province, coordinates, state
os> source=flatten | flatten location | fields name, country, province, coordinates, state
fetched rows / total rows = 4/4
+------------------+---------------+------------------+-----------------------------------------------+------------+
| name | country | province | coordinates | state |
Expand All @@ -42,7 +42,7 @@ Example 2: Flatten multiple object fields

PPL query::

os> source=cities | flatten location | flatten coordinates | fields name, country, province, state, latitude, longitude
os> source=flatten | flatten location | flatten coordinates | fields name, country, province, state, latitude, longitude
fetched rows / total rows = 4/4
+------------------+---------------+------------------+------------+----------+-----------+
| name | country | province | state | latitude | longitude |
Expand All @@ -58,7 +58,7 @@ Example 3: Flatten a nested object field

PPL query::

os> source=cities | flatten location.coordinates | fields name, location
os> source=flatten | flatten location.coordinates | fields name, location
fetched rows / total rows = 4/4
+------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| name | location |
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions doctest/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
DATASOURCES = ".ql-datasources"
WEBLOGS = "weblogs"
JSON_TEST = "json_test"
CITIES = "cities"
FLATTEN = "flatten"

class DocTestConnection(OpenSearchConnection):

Expand Down Expand Up @@ -126,7 +126,7 @@ def set_up_test_indices(test):
load_file("datasources.json", index_name=DATASOURCES)
load_file("weblogs.json", index_name=WEBLOGS)
load_file("json_test.json", index_name=JSON_TEST)
load_file("cities.json", index_name=CITIES)
load_file("flatten.json", index_name=FLATTEN)

def load_file(filename, index_name):
# Create index with the mapping if mapping file exists
Expand Down Expand Up @@ -154,7 +154,7 @@ def set_up(test):

def tear_down(test):
# drop leftover tables after each test
test_data_client.indices.delete(index=[ACCOUNTS, EMPLOYEES, PEOPLE, ACCOUNT2, NYC_TAXI, BOOKS, APACHE, WILDCARD, NESTED, WEBLOGS, JSON_TEST, CITIES], ignore_unavailable=True)
test_data_client.indices.delete(index=[ACCOUNTS, EMPLOYEES, PEOPLE, ACCOUNT2, NYC_TAXI, BOOKS, APACHE, WILDCARD, NESTED, WEBLOGS, JSON_TEST, FLATTEN], ignore_unavailable=True)


docsuite = partial(doctest.DocFileSuite,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import static org.opensearch.sql.legacy.TestUtils.getAliasIndexMapping;
import static org.opensearch.sql.legacy.TestUtils.getBankIndexMapping;
import static org.opensearch.sql.legacy.TestUtils.getBankWithNullValuesIndexMapping;
import static org.opensearch.sql.legacy.TestUtils.getCitiesIndexMapping;
import static org.opensearch.sql.legacy.TestUtils.getFlattenIndexMapping;
import static org.opensearch.sql.legacy.TestUtils.getDataTypeNonnumericIndexMapping;
import static org.opensearch.sql.legacy.TestUtils.getDataTypeNumericIndexMapping;
import static org.opensearch.sql.legacy.TestUtils.getDateIndexMapping;
Expand Down Expand Up @@ -760,11 +760,11 @@ public enum Index {
"json",
getJsonTestIndexMapping(),
"src/test/resources/json_test.json"),
CITIES(
TestsConstants.TEST_INDEX_CITIES,
"cities",
getCitiesIndexMapping(),
"src/test/resources/cities.json"),
FLATTEN(
TestsConstants.TEST_INDEX_FLATTEN,
"flatten",
getFlattenIndexMapping(),
"src/test/resources/flatten.json"),
DATA_TYPE_ALIAS(
TestsConstants.TEST_INDEX_ALIAS,
"alias",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ public static String getAliasIndexMapping() {
return getMappingFile(mappingFile);
}

public static String getCitiesIndexMapping() {
String mappingFile = "cities.mapping.json";
public static String getFlattenIndexMapping() {
String mappingFile = "flatten_mapping.json";
return getMappingFile(mappingFile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class TestsConstants {
public static final String TEST_INDEX_GEOPOINT = TEST_INDEX + "_geopoint";
public static final String TEST_INDEX_JSON_TEST = TEST_INDEX + "_json_test";
public static final String TEST_INDEX_ALIAS = TEST_INDEX + "_alias";
public static final String TEST_INDEX_CITIES = TEST_INDEX + "_cities";
public static final String TEST_INDEX_FLATTEN = TEST_INDEX + "_flatten";
public static final String TEST_INDEX_GEOIP = TEST_INDEX + "_geoip";
public static final String DATASOURCES = ".ql-datasources";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package org.opensearch.sql.ppl;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_CITIES;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_FLATTEN;
import static org.opensearch.sql.util.MatcherUtils.assertJsonEquals;

import com.google.common.io.Resources;
Expand All @@ -21,7 +21,7 @@ public class ExplainIT extends PPLIntegTestCase {
@Override
public void init() throws IOException {
loadIndex(Index.ACCOUNT);
loadIndex(Index.CITIES);
loadIndex(Index.FLATTEN);
}

@Test
Expand Down Expand Up @@ -131,7 +131,7 @@ public void testTrendlineWithSortPushDownExplain() throws Exception {

@Test
public void testFlatten() throws Exception {
String query = StringUtils.format("source=%s | flatten location", TEST_INDEX_CITIES);
String query = StringUtils.format("source=%s | flatten location", TEST_INDEX_FLATTEN);
String actual = explainQueryToString(query);
String expected = loadFromFile("expectedOutput/ppl/explain_flatten.json");
assertJsonEquals(expected, actual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package org.opensearch.sql.ppl;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_CITIES;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_FLATTEN;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
Expand All @@ -21,15 +21,15 @@ public class FlattenCommandIT extends PPLIntegTestCase {

@Override
public void init() throws IOException {
loadIndex(Index.CITIES);
loadIndex(Index.FLATTEN);
}

@Test
public void testBasic() throws IOException {
String query =
StringUtils.format(
"source=%s | flatten location | fields name, country, province, coordinates, state",
TEST_INDEX_CITIES);
TEST_INDEX_FLATTEN);
JSONObject result = executeQuery(query);

verifySchema(
Expand Down Expand Up @@ -63,7 +63,7 @@ public void testMultiple() throws IOException {
StringUtils.format(
"source=%s | flatten location | flatten coordinates | fields name, country, province,"
+ " state, latitude, longitude",
TEST_INDEX_CITIES);
TEST_INDEX_FLATTEN);
JSONObject result = executeQuery(query);

verifySchema(
Expand All @@ -86,7 +86,7 @@ public void testMultiple() throws IOException {
public void testNested() throws IOException {
String query =
StringUtils.format(
"source=%s | flatten location.coordinates | fields name, location", TEST_INDEX_CITIES);
"source=%s | flatten location.coordinates | fields name, location", TEST_INDEX_FLATTEN);
JSONObject result = executeQuery(query);

verifySchema(result, schema("name", "string"), schema("location", "struct"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
"name": "OpenSearchIndexScan",
"description": {
"request": "OpenSearchQueryRequest(indexName=opensearch-sql_test_index_cities, sourceBuilder={\"from\":0,\"size\":10000,\"timeout\":\"1m\"}, needClean=true, searchDone=false, pitId=null, cursorKeepAlive=null, searchAfter=null, searchResponse=null)"
"request": "OpenSearchQueryRequest(indexName=opensearch-sql_test_index_flatten, sourceBuilder={\"from\":0,\"size\":10000,\"timeout\":\"1m\"}, needClean=true, searchDone=false, pitId=null, cursorKeepAlive=null, searchAfter=null, searchResponse=null)"
},
"children": []
}
Expand Down
File renamed without changes.

0 comments on commit bd8942d

Please sign in to comment.