Hydra : how to assign config files from same group to two different fields - hydra

Here is my config directory structure,
config
|
--scenes
|
-- aaa.yaml
-- bbb.yaml
-- ccc.yaml
-- myconfig.yaml
aaa.yaml
--------
field_xxx: "someval"
field_yyy: "someval"
field_zzz: "someval"
bbb.yaml
--------
field_xxx: "someval"
field_yyy: "someval"
field_zzz: "someval"
myconfig.yaml has two fields src_scene and dst_scene. Currently I've hardcoded the fields and values for aaa.yaml and bbb.yaml into myconfig.yaml as follows,
myconfig.yaml
-------
src_scene:
field_xxx: "someval"
field_yyy: "someval"
field_zzz: "someval"
dst_scene:
field_xxx: "someval"
field_yyy: "someval"
field_zzz: "someval"
Ideally, I want to be able to assign these fields values from any of the config files in scenes group. Something like below,
src_scene: scenes/aaa.yaml
dst_scene: scenes/bbb.yaml
What is the right way of achieving this?

If you want to use the same config group multiple times, you can use package override.
Read the whole page, but look in particular at the last section.

Related

QlikView/SQL - If statement w/ IsNull

The logic for the problem is that I am attempting to resolve an issue where a certain field will return a null value and I would like to auto-generate a value for this field to that of another similar value given that its other relevant fields are the same.
Example (for both results):
*GradYear: 2018 ----
StudentName: Jake ----
*SchoolNumber: 54 ----
*StateCode: NA11 ----
CountyCode: MA02 ----
*SchoolName: Hillsburn ----
*GradYear: 2018 ----
StudentName: Sarah ----
*SchoolNumber: 54 ----
*StateCode: NA11 ----
CountyCode: NULL ----
*SchoolName: Hillsburn ----
As seen above, the CountCody for Sarah returns a null value. I am attempting to make it so that it will automatically fill the value for CountyCode, if the other similar values are the same between Students. (The necessary similar values being shown with a '*'.)
Also, I am attempting to solve this without using the "Previous" feature or hard-coded information so that it may be accomplished with any data.
My original attempt was to use a simple if/IsNull statement along with a Peek feature but the values persisted at returning a null value.
if((isnull(CountyCode)), Peek(CountyCode), CountyCode) as CountyCode
Any help with this would be greatly appreciated! Thank you in advance.
I would use applymap for this.
lets says the SchoolNumber is unique to CountyCode.
so first lets load our mapping table:
CountyCode_Map:
mapping load distinct SchoolNumber, CountyCode
from Data.qvd (qvd) where len(CountyCode)>0;
Now when loading you data use this for CountyCode:
applymap('CountyCode_Map',SchoolNumber) as CountyCode
in case that SchoolNumber is not unique to CountyCode you can use any other field or a concatenation of fields.
for more info on applymap : link

Query to return rows that have different values in two columns in Oracle

I am trying to write SQL query to get records that have different values between the customer and the external columns.
login customer external
-------- ---------- --------
william will200 will201
haymen hay100 hay100
norman nor345 nor346
bernie ber23 ber23
william1 will100 will101
max max65 max65
norman1 nor789 nor790
Output should be
login customer external
-------- -------- --------
william will200 will201
william1 will100 will101
norman nor345 nor346
norman1 nor789 nor790
I tried different queries but couldn't retrieve the desired output.
Any suggestions?
Thanks
I think your question is: "get records that DO NOT have duplicate values on 2 columns". This is based on your result set and sample data.
If so:
select t.*
from t
where login <> customer and customer <> external and login <> external;
At the very least, this returns the rows for your desired results.

informatica show the latest Status based on 2 attributes

I need to show the latest Status based on 2 attributes (LAST_UPDATE and STAUS)
How can I do it in informatica? the source is flat file
Example:
NUMBER --------------------LAST_UPDATE ----------------- STATUS
-----1 -----------------------01/26/2015 ---------------------- CREATED
-----1 ---------------------- 01/27/2015 ------------------UNDER_PROCCESS
-----1---------------------- 01/28/2015 ---------------------COMPLETED
-----2---------------------- 01/28/2015 ------------------ CREATED
-----3---------------------- 01/28/2015 --------------------- UNDER_PROCCESS
Result should be
NUMBER --------------------LAST_UPDATE ------------- STATUS ---------------LAST_STAUS
-----1 -----------------------01/26/2015 ---------------------- CREATED -----------COMPLETED
-----1 ---------------------- 01/27/2015 -----------------UNDER_PROCCESS ---- COMPLETED
-----1---------------------- 01/28/2015 ---------------------COMPLETED ----------COMPLETED
-----2---------------------- 01/28/2015 ------------------ CREATED ---------------- CREATED
-----3---------------------- 01/28/2015 -------------UNDER_PROCCESS --UNDER_PROCCESS
You can either use an Aggregator transformation or do it in an Expression transformation using variable ports.
Using Aggregator
In a sorter transformation, sort on NUMBER and LAST_UPDATE, in ascending order
In aggregator group by on NUMBER. Optionally use the LAST function to get the latest status. By default Aggregator will output the value for last row for STATUS.
Use a joiner to join the output of Aggregator and Sorter.
SQ ----> Sorter -----> Agg----> Joiner ----> Target
|_____________________^
Using Expression
Sort the data on NUMBER (ascending) and LAST_UPDATE (descending)
In expression transformation:
NUMBER (i/o)
LAST_UPDATE (i/o)
STATUS (i/o)
v_LAST_STATUS (v) = IIF(STATUS<>v_PREV_STATUS, STATUS,v_PREV_STATUS)
LAST_STATUS (o) = v_LAST_STATUS
v_PREV_STATUS (v) = STATUS
Make sure the order of ports is correct.

How to store Log in database?

My application let users to send files to each other. Regular users can edit their contacts, change password, etc. In addition, admin users can add/remove users and view the log of what happened. My question is how to store this log in MySQL database ?
I thought to store the log like this:
log_id time user_id action_type description
------ ---- ------- ---------------- ----------------------------------------
1 .... 4 User added Added new user: alex
2 .... 1 Contact added Added contact Paul to group Family
3 .... 1 User removed Removed user: gabrielle
4 .... 3 Files sent Sent files 3,5,7,14 to contacts 2,4,8
5 .... 8 Group added Added new group: Family
6 .... 8 Password changed
7 .... 8 First Name changed Changed First Name from Michael to Misha
What type would be the best for action_type ? Since new action_types may be added in future, I thought that ENUM won't be a good choice. So I thought to make it VARCHAR(..), like description.
Is this seems reasonable ?
I will be happy to hear any comments / suggestions.
If you're concerned about adding additional action types, make a separate table to store your action types and and join it to your logs table with a foreign key:
logs table:
log_id time user_id action_type_id description
------ ---- ------- ---------------- -----------------------------------
1 .... 4 1 Added new user: alex
2 .... 1 2 Added contact Paul to group Family
...
action_types table:
id name
--- ---------------
1 User added
2 Contact added
.....

SQL Alternative to performing an INNER JOIN on a single table

I have a large table (TokenFrequency) which has millions of rows in it. The TokenFrequency table that is structured like this:
Table - TokenFrequency
id - int, primary key
source - int, foreign key
token - char
count - int
My goal is to select all of the rows in which two sources have the same token in it. For example if my table looked like this:
id --- source --- token --- count
1 ------ 1 --------- dog ------- 1
2 ------ 2 --------- cat -------- 2
3 ------ 3 --------- cat -------- 2
4 ------ 4 --------- pig -------- 5
5 ------ 5 --------- zoo ------- 1
6 ------ 5 --------- cat -------- 1
7 ------ 5 --------- pig -------- 1
I would want a SQL query to give me source 1, source 2, and the sum of the counts. For example:
source1 --- source2 --- token --- count
---- 2 ----------- 3 --------- cat -------- 4
---- 2 ----------- 5 --------- cat -------- 3
---- 3 ----------- 5 --------- cat -------- 3
---- 4 ----------- 5 --------- pig -------- 6
I have a query that looks like this:
SELECT F.source AS source1, S.source AS source2, F.token,
(F.count + S.count) AS sum
FROM TokenFrequency F
INNER JOIN TokenFrequency S ON F.token = S.token
WHERE F.source <> S.source
This query works fine but the problems that I have with it are that:
I have a TokenFrequency table that has millions of rows and therefore need a faster alternative to obtain this result.
The current query that I have is giving duplicates. For example its selecting:
source1=2, source2=3, token=cat, count=4
source1=3, source2=2, token=cat, count=4
Which isn't too much of a problem but if there is a way to elimate those and in turn obtain a speed increase then it would be very useful
The main issue that I have is speed of the query with my current query it takes hours to complete. The INNER JOIN on a table to itself is what I believe to be the problem. Im sure there has to be a way to eliminate the inner join and get similar results just using one instance of the TokenFrequency table. The second problem that I mentioned might also promote a speed increase in the query.
I need a way to restructure this query to provide the same results in a faster, more efficient manner.
Thanks.
I'd need a little more info to diagnose the speed issue, but to remove the dups, add this to the WHERE:
AND F.source<S.source
Try this:
SELECT token, GROUP_CONCAT(source), SUM(count)
FROM TokenFrequency
GROUP BY token;
This should run a lot faster and also eliminate the duplicates. But the sources will be returned in a comma-separated list, so you'll have to explode that in your application.
You might also try creating a compound index over the columns token, source, count (in that order) and analyze with EXPLAIN to see if MySQL is smart enough to use it as a covering index for this query.
update: I seem to have misunderstood your question. You don't want the sum of counts per token, you want the sum of counts for every pair of sources for a given token.
I believe the inner join is the best solution for this. An important guideline for SQL is that if you need to calculate an expression with respect to two different rows, then you need to do a join.
However, one optimization technique that I mentioned above is to use a covering index so that all the columns you need are included in an index data structure. The benefit is that all your lookups are O(log n), and the query doesn't need to do a second I/O to read the physical row to get other columns.
In this case, you should create the covering index over columns token, source, count as I mentioned above. Also try to allocate enough cache space so that the index can be cached in memory.
If token isn't indexed, it certainly should be.