I am creating a "temporary" (transition) table : "Abis" which must be the copy (identical structure) of a table "A" with the addition of data and the update of several fields via other tables more recent (B, C, D, E).
I have a primary key based on 2 fields in "A" (A.a and A.b) that is present in "Abis" (Abis.a and Abis.b) as well as in "B" (B.a and B.b).
I made a full join between A and B: A.a = B.a and A.b = B.b.
What mapping I have to put to feed my "Abis" table on Abis.a and Abis.b, recovering all key combinations of A (A.a + A.b) as well as all key combinations of B (B.a + B.b) that aren't present in A.
I tested with
"Case When A.a Not In B.a Than A.a Else B.a End"
But the query turns indefinitely.
To sum up:
Target Datastore: Abis
Diagram: A, B, C, D, E
Join: A.a = B.a and A.b = B.b (Full join)
Number of row: Table A ~ 6000, Table B ~ 40000
Software: ODI 10.1.3.5 (Oracle Data Integrator)
Thanks :)
Ok I almost solved my problem with the DECODE function
I tried the NVL function but it did not give exactly what I wanted.
The similar function to NVL is DECODE.
https://www.techonthenet.com/oracle/functions/decode.php
Mapping on Abis.a > Decode (A.a, 0, B.a, A.a)
Mapping on Abis.b > Decode (A.b, 0, B.b, A.b)
Related
Hi I have a pig script like this. When doing foreach statement it throws invalid scalar projection error.Here is my code.
a = load 'file' using PigStorage(':');
b = group a by ($1, $7, $11);
c = foreach b generate flatten(group), COUNT(a) as (cnt: int);
d = filter c by cnt>1;
e = foreach d generate flatten(a) ;
The error is shown below
<line 6, column 31> Invalid scalar projection: a : A column needs to be projected from a relation for it to be used as a scalar
Any help will be appreciated.
The issue is because, 'a' doesn's exists in the 'd' relation schema.
describe the 'd' schema, you get:
d: {bytearray,bytearray,bytearray, cnt: int} in which 'a' doesn't exists.
In the script, C relation is formed, by Projection of flattening the group field and Number of elements of a, a is not included in the relation C.
I need select from tarantool all datat by two values from one space.
How i can perform request to tarantool like in mysql?
select from aaa where a=1a22cadbdb or a=7f626e0123
Now i can make two requests:
box.space.logs:select({'1a22cadbdb'})
box.space.logs:select({'7f626e0123'})
but i don't know how to merge result into one ;(
Following code merge field[0] to lua table
a = box.space.logs:select({'1a22cadbdb'})
b = box.space.logs:select({'7f626e0123'})
c = { field_1 = a[0], field_2 = b[0] }
The select return tuple or tuples so you can extract value via [].
More details about select: http://tarantool.org/doc/book/box/box_index.html?highlight=select#lua-function.index_object.select
More details about tuple: http://tarantool.org/doc/book/box/box_tuple.html?highlight=tuple#lua-module.box.tuple
Nowadays Tarantool allows you to retrieve via SQL, for example box.execute([[select from "aaa" where "a"='1a22cadbdb' or "a"='7f626e0123';]]). You have to add the field names and types of aaa before doing this, with the format() function.
For me this work fine, but need make check for return from first select:
local res = {}
for k, v in pairs (box.space.email:select({email})[1]) do
if type(v) == 'string' then
table.insert(res, box.space.logs:select({v})[1])
end
end
I'm porting some sql stored procedure logic, which would return multiple tables in a dataset, to entity framework strongly typed objects, queried with linq.
Basically I need the data from tables A, B, and C, where C has a foreign key to B, and B has a foreign key to A. But I don't want every C with a FK to B, just the C's with a certain constraint X.
So basically, the stored proc basically said
TableA = select from A where A.AID = AIDPassedIn
TableB = select from B where B.AID = AIDPassedIn
TableC = select from TableB where TableB.XID = XIDPassedIn
return new DataSet(TableA, TableB, TableC);
//yes this is gross and confusing, thus our current efforts
Entity framework almost makes this super easy like so
A.Include("B.C").Where(a => a.AID == AIDPassedIn)
My only problem is that this doesn't include constraint X on the C table. I've read a bunch of articles, but everything I've read suggests things I could add to the where clause, and that would filter what A objects I end up with. I should only end up with one A object though, regardless of the properties of it's children. What I want is The A with AIDPassedIn, and all it's child B's, and all the B's children C that match constraint X.
I feel like this is one of my worst phrased questions ever but I'm at a bit of a block. Any help would be great thanks!
You can try it along the lines of the following:
var AList = context.As.Where(a => a.AID == AIDPassedIn)
.Select(a => new
{
A = a,
Bs = a.Bs,
Cs = a.Bs.Select(b => b.Cs.Where(c => c.XID == XIDPassedIn))
})
.AsEnumerable()
.Select(x => x.A)
.ToList(); // or SingleOrDefault if AIDPassedIn is the PK
Entity Framework will put the object graph together automatically (even without using Include) as long as you don't disable change tracking.
I have two tables, one contains entities other entitylog.
MyEntity:
id, lat, lon
A entity has a position in the world.
MyEntityLog:
id, otherid, otherlat, otherlon
Entity with id has interacted with otherid at otherid's latitude and longitude.
For instance, I have the following entities:
1, 4.456, 2.234
2, 3.344, 6.453
3, 6.234, 9.324
(not very accurate, but it serves the purpose).
Now, If entity 1 interact with 2 the result on the log table would look like:
1, 2, 3.344, 6.453
So my question is, how can I for listing entity 1's available interactions NOT include the ones on the log table?
The result of listing entity 1's available interactions should be only be entity 3 as it already has a interaction with 2.
First make a list of ids that interact with entity 1:
var id1 = 1;
var excluded = from l in db.EntityLogs
where l.id == id1
select l.otherid;
then find the entries not having an id in this list or equal to id1:
var logs= from l in db.EntityLogs
where !excluded.Contains(l.id) && l.id != id1
select l;
Note that linq will defer the execution of excluded and incorporate it in the execution of logs.
Not sure if I understand your question, I guess I need more details, but if you want to list the entities that have no entry in log table, one solution will be something like this, assuming myEntities is the collection of MyEntity and myEntityLogs is the collection of MyEntityLog
var firstList = myEntities.Join(myEntityLogs, a => a.Id, b => b.Id, (a, b) => a).Distinct();
var secondList = myEntities.Join(myEntityLogs, a => a.Id, b => b.OtherId, (a, b) => a).Distinct();
var result = myEntities.Except(firstList.Concat(secondList)).ToList();
in my report.rptdesign, I have 3 tables and all of them grouped by common element. currently it is creating document as follows : (Assume my 3 tables A, B,C)
A
A
A
...
B
B
B
...
C
C
C
...
But I want to have as following :
A
A
A
...
B
C
B
C
B
C
...
... = so and so forth
Any suggestions on how to achieve this ?
Thanks
I think, it can be achieved by something like "artifical grouping".
Try to create tables B, C within a one-column table MASTER:
MASTER table
[header row]
[detail row]
group data
B table
[header row]
[detail row]
b data
[footer row]
C table
[header row]
[detail row]
c data
[footer row]
Bound MASTER to Data Set, which selects groups only (e.g.SELECT DISTINCT groupingColumn FROM myTable).
Bound B to selection which has parameter for groupingColumn (e.g.SELECT x, y, z FROM foo WHERE groupingColumn = ?). This selection will execute for each row in the MASTER table, so consider performance issues here.
Connect property in table B binding with MASTERs groupingColumn:
In a Property Editor for table B open Binding tab -> Data Set Parameter Binding... -> edit -> open expression builder -> Available Column Bindings -> Table MASTER -> groupingColumn.
The same way for C, of course.