logic for making them all into a union is a bit trickier in reality, but that's the gist of it. the
markerColumn
here is for knowing which input produced a given row.
But how can I get the value of the
markerColumn
from a given
ResultRow
?
The way it's currently done does not spark joy:
row[row.fieldIndex.keys.last()] as Int
s
spand
01/05/2024, 1:14 PM
doesnt
row[markerColumn]
work ?
a
Alexander
01/05/2024, 1:15 PM
because I need the index when creating the marker column it has to be created within the map, so it's unique for each query in the union.
Alexander
01/05/2024, 1:17 PM
ideally I'd have something like:
Copy code
val columnAlias = Column<Int>("inputSource")
val queries = inputs.mapIndexed { idx, input ->
val markerColumn = intLiteral(idx).alias(columnAlias)
// same as above...
followed by
row[columnAlias]
but I haven't figured out a way to do that. If I do
MyTable.integer("inputSource")
it almost works, but says that there's an unknown column in the result set or something.
s
spand
01/05/2024, 1:25 PM
I dont think it works but I guess exposed ought to work like this:
Copy code
val alias = intLiteral(-1).alias("inputSource").aliasOnlyExpression()
...
val byString = row[alias]
spand
01/05/2024, 1:26 PM
But looking at the code it seems to boil down to identity equality
spand
01/05/2024, 1:26 PM
Seems like a good case to have supported. You should make a feature request
a
Alexander
01/05/2024, 1:36 PM
Will do that. Figured I might be missing something, but maybe it's just not possible atm. I think what's needed is some way to add extra columns, because looking in the debugger the key is the literal itself, so it probably isn't possible to get it without knowing what the value is.
So using