@@ -1881,6 +1881,56 @@ class AbstractScalaEsScalaSparkSQL(prefix: String, readMetadata: jl.Boolean, pus
1881
1881
assertThat(array(1 ), is(0.0d ))
1882
1882
}
1883
1883
1884
+ @ Test
1885
+ def testGeoShapePointDeep () {
1886
+ val mapping = wrapMapping(" data" , s """ {
1887
+ | "properties": {
1888
+ | "name": {
1889
+ | "type": " $keyword"
1890
+ | },
1891
+ | "location": {
1892
+ | "properties": {
1893
+ | "deep": {
1894
+ | "type": "geo_shape"
1895
+ | }
1896
+ | }
1897
+ | }
1898
+ | }
1899
+ | }
1900
+ """ .stripMargin)
1901
+
1902
+ val index = wrapIndex(" sparksql-test-geoshape-point-geoshape-deep" )
1903
+ val typed = " data"
1904
+ val (target, _) = makeTargets(index, typed)
1905
+ RestUtils .touch(index)
1906
+ RestUtils .putMapping(index, typed, mapping.getBytes(StringUtils .UTF_8 ))
1907
+
1908
+ val point = """ {"name":"point", "location": { "deep":{ "type" : "point", "coordinates": [100.0, 0.0] } }}""" .stripMargin
1909
+
1910
+ sc.makeRDD(Seq (point)).saveJsonToEs(target)
1911
+ val df = sqc.read.format(" es" ).load(index)
1912
+
1913
+ println(df.schema.treeString)
1914
+
1915
+ val dataType = df.schema(" location" ).dataType.asInstanceOf [StructType ](" deep" ).dataType
1916
+ assertEquals(" struct" , dataType.typeName)
1917
+
1918
+ val struct = dataType.asInstanceOf [StructType ]
1919
+ assertTrue(struct.fieldNames.contains(" type" ))
1920
+ var coords = struct(" coordinates" ).dataType
1921
+ assertEquals(" array" , coords.typeName)
1922
+ coords = coords.asInstanceOf [ArrayType ].elementType
1923
+ assertEquals(" double" , coords.typeName)
1924
+
1925
+ val head = df.select(" location.*" ).head()
1926
+
1927
+ val obj = head.getStruct(0 )
1928
+ assertThat(obj.getString(0 ), is(" point" ))
1929
+ val array = obj.getSeq[Double ](1 )
1930
+ assertThat(array(0 ), is(100.0d ))
1931
+ assertThat(array(1 ), is(0.0d ))
1932
+ }
1933
+
1884
1934
@ Test
1885
1935
def testGeoShapeLine () {
1886
1936
val mapping = wrapMapping(" data" , s """ {
@@ -1905,7 +1955,7 @@ class AbstractScalaEsScalaSparkSQL(prefix: String, readMetadata: jl.Boolean, pus
1905
1955
1906
1956
sc.makeRDD(Seq (line)).saveJsonToEs(target)
1907
1957
val df = sqc.read.format(" es" ).load(index)
1908
-
1958
+
1909
1959
val dataType = df.schema(" location" ).dataType
1910
1960
assertEquals(" struct" , dataType.typeName)
1911
1961
0 commit comments