Skip to content

Commit eb0fbf5

Browse files
committed
Simplify python test_sql that has been failing on travis
Signed-off-by: Jason T. Brown <[email protected]>
1 parent f69227a commit eb0fbf5

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

pyrasterframes/src/main/python/tests/PyRasterFramesTests.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -228,28 +228,23 @@ def test_aggregations(self):
228228
self.assertEqual(row['rf_agg_stats(tile)'].data_cells, row['rf_agg_data_cells(tile)'])
229229

230230
def test_sql(self):
231-
self.rf.createOrReplaceTempView("rf")
232-
233-
dims = self.rf.withColumn('dims', rf_dimensions('tile')).first().dims
234-
dims_str = """{}, {}""".format(dims.cols, dims.rows)
235-
236-
self.spark.sql("""SELECT tile, rf_make_constant_tile(1, {}, 'uint16') AS One,
237-
rf_make_constant_tile(2, {}, 'uint16') AS Two FROM rf""".format(dims_str, dims_str)) \
238-
.createOrReplaceTempView("r3")
239-
240-
ops = self.spark.sql("""SELECT tile, rf_local_add(tile, One) AS AndOne,
241-
rf_local_subtract(tile, One) AS LessOne,
242-
rf_local_multiply(tile, Two) AS TimesTwo,
243-
rf_local_divide(tile, Two) AS OverTwo
244-
FROM r3""")
245-
246-
# ops.printSchema
247-
statsRow = ops.select(rf_tile_mean('tile').alias('base'),
248-
rf_tile_mean("AndOne").alias('plus_one'),
249-
rf_tile_mean("LessOne").alias('minus_one'),
250-
rf_tile_mean("TimesTwo").alias('double'),
251-
rf_tile_mean("OverTwo").alias('half')) \
252-
.first()
231+
self.rf.createOrReplaceTempView("rf_test_sql")
232+
233+
self.spark.sql("""SELECT tile,
234+
rf_local_add(tile, 1) AS and_one,
235+
rf_local_subtract(tile, 1) AS less_one,
236+
rf_local_multiply(tile, 2) AS times_two,
237+
rf_local_divide(tile, 2) AS over_two
238+
FROM rf_test_sql""").createOrReplaceTempView('rf_test_sql_1')
239+
240+
statsRow = self.spark.sql("""
241+
SELECT rf_tile_mean(tile) as base,
242+
rf_tile_mean(and_one) as plus_one,
243+
rf_tile_mean(less_one) as minus_one,
244+
rf_tile_mean(times_two) as double,
245+
rf_tile_mean(over_two) as half
246+
FROM rf_test_sql_1
247+
""").first()
253248

254249
self.assertTrue(self.rounded_compare(statsRow.base, statsRow.plus_one - 1))
255250
self.assertTrue(self.rounded_compare(statsRow.base, statsRow.minus_one + 1))

0 commit comments

Comments
 (0)