Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RD-10763: Replace maybeType by a Decl in ProgramDescription #385

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package raw.client.api

final case class ProgramDescription(
decls: Map[String, List[DeclDescription]],
maybeType: Option[RawType],
maybeRunnable: Option[DeclDescription],
comment: Option[String]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class Rql2TruffleCompilerService(engineDefinition: (Engine, Boolean), maybeClass
formattedDecls,
maybeType.map { t =>
rql2TypeToRawType(t) match {
case Some(rawType) => rawType
case Some(rawType) => DeclDescription(None, rawType, None)
case None => return GetProgramDescriptionFailure(
List(ErrorMessage(UnsupportedType.message, List.empty, UnsupportedType.code))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class SqlCompilerService(maybeClassLoader: Option[ClassLoader] = None)(implicit
// Regardless if there are parameters, we declare a main function with the output type.
// This permits the publish endpoints from the UI (https://raw-labs.atlassian.net/browse/RD-10359)
val ok = ProgramDescription(
Map("main" -> List(DeclDescription(Some(ps.toVector), iterableType, None))),
None,
Map.empty,
Some(DeclDescription(Some(ps.toVector), iterableType, None)),
None
)
GetProgramDescriptionSuccess(ok)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,6 @@ class TestNamedParametersStatement extends RawTestSuite with SettingsTestContext
super.afterAll()
}

test("bug") { _ =>
assume(password != "")

val code = """-- @type aeroport_id smallint
|SELECT :city::json FROM example.airports WHERE airport_id = :aeroport_id""".stripMargin

val statement = new NamedParametersPreparedStatement(con, parse(code))
val metadata = statement.queryMetadata
assert(metadata.isLeft)
statement.setString("v1", "Hello!")
val rs = statement.executeQuery()

rs.next()
assert(rs.getString("arg") == "Hello!")
}

test("single parameter") { _ =>
assume(password != "")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
val v = compilerService.validate(t.q, environment)
assert(v.messages.isEmpty)
val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, environment)
assert(description.maybeType.isEmpty)
val List(main) = description.decls("main")
assert(description.decls.isEmpty)
val Some(main) = description.maybeRunnable
assert(
main.outType == airportType
)
Expand Down Expand Up @@ -409,8 +409,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
val v = compilerService.validate(t.q, environment)
assert(v.messages.isEmpty)
val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, environment)
assert(description.maybeType.isEmpty)
val List(main) = description.decls("main")
assert(description.decls.isEmpty)
val Some(main) = description.maybeRunnable
assert(
main.outType == airportType
)
Expand Down Expand Up @@ -448,8 +448,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
val v = compilerService.validate(t.q, environment)
assert(v.messages.isEmpty)
val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, environment)
assert(description.maybeType.isEmpty)
val List(main) = description.decls("main")
assert(description.decls.isEmpty)
val Some(main) = description.maybeRunnable
assert(
main.outType == airportType
)
Expand Down Expand Up @@ -598,8 +598,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
val v = compilerService.validate(t.q, withCity)
assert(v.messages.isEmpty)
val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, withCity)
assert(description.maybeType.isEmpty)
val List(main) = description.decls("main")
assert(description.decls.isEmpty)
val Some(main) = description.maybeRunnable
assert(
main.outType == RawIterableType(
RawRecordType(Vector(RawAttrType("count", RawLongType(true, false))), false, false),
Expand Down Expand Up @@ -644,8 +644,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
val v = compilerService.validate(t.q, withCity)
assert(v.messages.isEmpty)
val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, withCity)
assert(description.maybeType.isEmpty)
val List(main) = description.decls("main")
assert(description.decls.isEmpty)
val Some(main) = description.maybeRunnable
assert(
main.outType == RawIterableType(
RawRecordType(Vector(RawAttrType("count", RawLongType(true, false))), false, false),
Expand Down Expand Up @@ -674,8 +674,8 @@ class TestSqlCompilerServiceAirports extends RawTestSuite with SettingsTestConte
val v = compilerService.validate(t.q, environment)
assert(v.messages.isEmpty)
val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, environment)
assert(description.maybeType.isEmpty)
val List(main) = description.decls("main")
assert(description.decls.isEmpty)
val Some(main) = description.maybeRunnable
assert(
main.outType == RawIterableType(
RawRecordType(
Expand Down
Loading