Skip to content

Commit

Permalink
Fix broken assertion in AbstractNessieSparkSqlExtensionTest
Browse files Browse the repository at this point in the history
The assertion was modified in projectnessie#7308 with a workaround to
avoid compilation failures.

This commit reintroduces the right assertion, which became
possible when Iceberg updated Nessie to 0.61+.
  • Loading branch information
adutra authored and snazy committed Sep 22, 2023
1 parent 6d4b965 commit 59cd91f
Show file tree
Hide file tree
Showing 6 changed files with 509 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,7 @@ additionalRefName, defaultBranch(), currentHash))
"ASSIGN BRANCH %s TO %s AT %s IN nessie",
additionalRefName, defaultBranch(), invalidHash))
.isInstanceOf(IllegalArgumentException.class)
// TODO enable this when Nessie lib will be >= 0.61
// .hasMessage(
// Validation.HASH_OR_RELATIVE_COMMIT_SPEC_MESSAGE
// + " - but was: "
// + invalidHash)
.hasMessageContaining(Validation.HASH_RULE)
.hasMessageContaining(" - but was: " + invalidHash);
.hasMessage(Validation.HASH_OR_RELATIVE_COMMIT_SPEC_MESSAGE + " - but was: " + invalidHash);
assertThatThrownBy(
() ->
sql(
Expand Down Expand Up @@ -324,13 +318,7 @@ additionalRefName, defaultBranch(), currentHash))
"ASSIGN TAG %s TO %s AT %s IN nessie",
additionalRefName, defaultBranch(), invalidHash))
.isInstanceOf(IllegalArgumentException.class)
// TODO enable this when Nessie lib will be >= 0.61
// .hasMessage(
// Validation.HASH_OR_RELATIVE_COMMIT_SPEC_MESSAGE
// + " - but was: "
// + invalidHash)
.hasMessageContaining(Validation.HASH_RULE)
.hasMessageContaining(" - but was: " + invalidHash);
.hasMessage(Validation.HASH_OR_RELATIVE_COMMIT_SPEC_MESSAGE + " - but was: " + invalidHash);
assertThatThrownBy(
() ->
sql(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright (C) 2022 Dremio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.catalyst.plans.logical

import org.apache.spark.sql.catalyst.expressions.AttributeReference
import org.apache.spark.sql.types.{DataTypes, Metadata, StructField, StructType}

object NessieCommandOutputs {
def referenceOutput(): Seq[AttributeReference] = new StructType(
Array[StructField](
StructField(
"refType",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"name",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"hash",
DataTypes.StringType,
nullable = false,
Metadata.empty
)
)
).toAttributes

def simpleReferenceOutput(): Seq[AttributeReference] = new StructType(
Array[StructField](
StructField(
"name",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"hash",
DataTypes.StringType,
nullable = false,
Metadata.empty
)
)
).toAttributes

def dropReferenceOutput(): Seq[AttributeReference] = new StructType(
Array[StructField](
StructField(
"status",
DataTypes.StringType,
nullable = false,
Metadata.empty
)
)
).toAttributes

def showLogOutput(): Seq[AttributeReference] = new StructType(
Array[StructField](
StructField(
"author",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"committer",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"hash",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"message",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"signedOffBy",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"authorTime",
DataTypes.TimestampType,
nullable = false,
Metadata.empty
),
StructField(
"committerTime",
DataTypes.TimestampType,
nullable = false,
Metadata.empty
),
StructField(
"properties",
DataTypes
.createMapType(DataTypes.StringType, DataTypes.StringType, false),
nullable = false,
Metadata.empty
)
)
).toAttributes
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright (C) 2022 Dremio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.catalyst.plans.logical

import org.apache.spark.sql.catalyst.expressions.AttributeReference
import org.apache.spark.sql.types.{DataTypes, Metadata, StructField, StructType}

object NessieCommandOutputs {
def referenceOutput(): Seq[AttributeReference] = new StructType(
Array[StructField](
StructField(
"refType",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"name",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"hash",
DataTypes.StringType,
nullable = false,
Metadata.empty
)
)
).toAttributes

def simpleReferenceOutput(): Seq[AttributeReference] = new StructType(
Array[StructField](
StructField(
"name",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"hash",
DataTypes.StringType,
nullable = false,
Metadata.empty
)
)
).toAttributes

def dropReferenceOutput(): Seq[AttributeReference] = new StructType(
Array[StructField](
StructField(
"status",
DataTypes.StringType,
nullable = false,
Metadata.empty
)
)
).toAttributes

def showLogOutput(): Seq[AttributeReference] = new StructType(
Array[StructField](
StructField(
"author",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"committer",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"hash",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"message",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"signedOffBy",
DataTypes.StringType,
nullable = false,
Metadata.empty
),
StructField(
"authorTime",
DataTypes.TimestampType,
nullable = false,
Metadata.empty
),
StructField(
"committerTime",
DataTypes.TimestampType,
nullable = false,
Metadata.empty
),
StructField(
"properties",
DataTypes
.createMapType(DataTypes.StringType, DataTypes.StringType, false),
nullable = false,
Metadata.empty
)
)
).toAttributes
}
Loading

0 comments on commit 59cd91f

Please sign in to comment.