The error is “A column or function parameter with name elevation
cannot be resolved.”
The Aggregate shown in the message has the quotes in strange places (I don’t know if that is what is causing the problem).
This only happens when running multiple tests in Junit in Intellij. I see that SparkSession.builder().getOrCreate() recycles SparkSessions, but even thwarting that with SparkSession.clearAciveSession() and SparkSession.clearDefaultSession() does not help. Setting the Run Configuration -> Fork Mode: class does solve the issue.
org.apache.spark.sql.AnalysisException: [UNRESOLVED_COLUMN.WITHOUT_SUGGESTION] A column or function parameter with name `elevation` cannot be resolved. ; line 1 pos 11;
'Aggregate ['country], ['max('elevation) AS el#237, 'min('runways) AS run#238, 'country]
+- SubqueryAlias airports
+- View (`airports`, [])
+- RelationV2[] ef04a7f8-8bec-43c8-920c-38d644a73dfb
@Test
def testPushDownAggregationWithGroupBy(): Unit = {
val airports = spark.read
.format("couchbase.query")
.option(QueryOptions.Filter, "type = 'airport'")
.option(QueryOptions.ScanConsistency, QueryOptions.RequestPlusScanConsistency)
.load()
airports.createOrReplaceTempView("airports")
val aggregates = spark.sql(
"select max(elevation) as el, min(runways) as run, country from airports group by country"
)
`