|
| 1 | +/* |
| 2 | + * |
| 3 | + * * Copyright OpenSearch Contributors |
| 4 | + * * SPDX-License-Identifier: Apache-2.0 |
| 5 | + * |
| 6 | + */ |
| 7 | + |
| 8 | +package org.opensearch.sql.calcite.remote; |
| 9 | + |
| 10 | +import static org.opensearch.sql.legacy.SQLIntegTestCase.Index.NESTED_WITHOUT_ARRAYS; |
| 11 | +import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_NESTED_TYPE_WITHOUT_ARRAYS; |
| 12 | +import static org.opensearch.sql.util.MatcherUtils.schema; |
| 13 | +import static org.opensearch.sql.util.MatcherUtils.verifyNumOfRows; |
| 14 | +import static org.opensearch.sql.util.MatcherUtils.verifySchema; |
| 15 | + |
| 16 | +import org.json.JSONObject; |
| 17 | +import org.junit.jupiter.api.Test; |
| 18 | +import org.opensearch.sql.ppl.PPLIntegTestCase; |
| 19 | + |
| 20 | +public class CalciteFlattenCommandIT extends PPLIntegTestCase { |
| 21 | + @Override |
| 22 | + public void init() throws Exception { |
| 23 | + super.init(); |
| 24 | + loadIndex(NESTED_WITHOUT_ARRAYS); |
| 25 | + enableCalcite(); |
| 26 | + disallowCalciteFallback(); |
| 27 | + } |
| 28 | + |
| 29 | + @Test |
| 30 | + public void testFlattenStruct() throws Exception { |
| 31 | + JSONObject result = |
| 32 | + executeQuery( |
| 33 | + String.format("source=%s | flatten message", TEST_INDEX_NESTED_TYPE_WITHOUT_ARRAYS)); |
| 34 | + verifySchema( |
| 35 | + result, |
| 36 | + schema("message", "struct"), |
| 37 | + schema("info", "string"), |
| 38 | + schema("author", "string"), |
| 39 | + schema("dayOfWeek", "integer"), |
| 40 | + schema("comment", "array"), |
| 41 | + schema("myNum", "integer"), |
| 42 | + schema("someField", "string")); |
| 43 | + verifyNumOfRows(result, 5); |
| 44 | + } |
| 45 | +} |
0 commit comments