How to perform parameterized date comparison with Azure Data Factory mapping data flows? - azure-mapping-data-flow

In mapping data flows I'm using the following filter expression against a late binding (schema drift) source:
toString(byName('modifiedon')) > '2022-04-19 00:00:00'
The filter expression returns the correct output. However I run into problems when I attempt to parameterize the expression using the following parameters:
For example, let's replace 'modifiedon' with a string type parameter as shown below:
toString(byName($WatermarkColumnName)) > '2022-04-19 00:00:00'
This will give me no output at all. If I try to parameterize the timestamp with a string type parameter I'll get the following error message when attempting data preview:
Incompatible data types between declared type and actual parameter value
I have tried defining the WatermarkValue parameter as TimeStamp and then using toString($WatermakValue) function in the filter expression but then it returns all records instead!

Related

Add a day to a datetime project parameter and store in a variable of type datetime in using SSIS expression

I am trying to add a day to a project parameter of type DATETIME and store the results in a variable in SSIS which of type DATETIME.
I am using this below expression in variable
dateadd(day,1,(DT_DATE)(DT_DBDATE) #[$Project::Start_Date])
and getting this below error
TITLE: Expression Builder
Expression cannot be evaluated.
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft%C2%AE%20Visual%20Studio%C2%AE%202015&ProdVer=14.0.23107.0&EvtSrc=Microsoft.DataTransformationServices.Controls.TaskUIFramework.TaskUIFrameworkSR&EvtID=FailToEvaluateExpression&LinkId=20476
------------------------------ ADDITIONAL INFORMATION:
The expression contains unrecognized token "day". If "day" is a
variable, it should be expressed as "#day". The specified token is not
valid. If the token is intended to be a variable name, it should be
prefixed with the # symbol.
Attempt to parse the expression "dateadd(day,1,(DT_DATE)(DT_DBDATE)
#[$Project::Start_Date])" failed and returned error code 0xC00470A4.
The expression cannot be parsed. It might contain invalid elements or
it might not be well-formed. There may also be an out-of-memory error.
(Microsoft.DataTransformationServices.Controls)
------------------------------ BUTTONS:
OK
Can anyone help me to resolve the above problem.
TL;DR;
The argument to the first parameter for dateadd is a string, not a constant/enumeration so it should be
dateadd("day",1,(DT_DATE)(DT_DBDATE) #[$Project::Start_Date])
The long way around
I assume the desire is to get the next day's date with the supplied expression
dateadd(day,1,(DT_DATE)(DT_DBDATE) #[$Project::Start_Date])
When I run into issues with expressions, I break them down into the most atomic statement and then compose from there.
I'm using a SSIS scoped variable instead of a project parameter but the logic will hold true.
I have an SSIS variable, Start_Date of data type DateTime with an initial value of 2022-06-01 09:22 AM (convert that to your current locale's preference for date presenation)
I created a new variable, Start_DateOnly and used the following expression
(DT_DATE)(DT_DBDATE) #[User::Start_Date]
Great, that shows 2022-06-01 (no time component in the Variables window although if you evaluate in the Expression editor, it will show midnight). And the explainer - we convert to the DT_DBDATE datatype to drop the time component but DT_DBDATE is incompatible with the displayed DateTime data type so we explicitly convert to DT_DATE.
Cool beans, now all we need to do is confirm the dateadd function works as expected with our new variable
dateadd(day, 1, #[User::Start_DateOnly])
What the heck?
Expression cannot be evaluated.
The expression contains unrecognized token "day". If "day" is a variable, it should be expressed as "#day". The specified token is not valid. If the token is intended to be a variable name, it should be prefixed with the # symbol.
Oh... yeah, while this language is similar to TSQL, the datepart parameter is a string, not an enum/constant so the syntax should be
dateadd("day", 1, #[User::Start_DateOnly])
Yup, that evaluates to 2022-06-02 12:00 AM

Handling dimension with empty names in icCube

How can I get icCube to handle a dimension where there are empty values in the backing table? I get the following error message from icCube when I try to scan our tables:
Data table 'public.accounting_area_dim', line '22' : The member key:'22' has no name (nameColumn:area) (level:[Area].[Area].[Area])
This is absolutely correct, there are empty strings in the dimension table - I'd like to treat it as "Unknown" or something similar, is this possible in icCube?
You can transform the empty string into something else within the table definition as following:
Hope that helps.

infomatica unconnected lookup invalid symbol reference error

I am getting invalid symbol reference for below expression in informatica cloud
decode(true,STAGE_NAME_CODE='S1',:LKP.Lkp_SFDC_description(CODE),0)
in the unconnected lookup i have three fields code,code_type and description, I want to return description for stage_name_code from source file from the unconnected lookup field Code
but he onlytime the expression is valid is when its written like this..
decode(true,STAGE_NAME_CODE='S1',:LKP.Lkp_SFDC_description(STAGE_NAME_CODE))
Rather than using DECODE, you can use IIF function.
IIF(STAGE_NAME_CODE='S1',:LKP.Lkp_SFDC_description(STAGE_NAME_CODE))
This provides you an exact result.
To have fun on ETL, play with https://etlinfromatica.wordpress.com/

Using UTCTime with SQLite in Yesod

While using a UTCTime field in my model in Yesod, I get the following error:
PersistMarshalError "field timestamp: Expected UTCTime, received PersistText \"09:18:07\""
I am using SQLite to store my database. My model looks as follows:
Myobject
timestamp UTCTime default=CURRENT_TIME
otherfield Text
Note that this error occurs both with and without the default value.
I am selecting the list of Myobject-entities as follows:
myobjects <- selectList [] [Desc MyobjectTimestamp]
Using MyobjectOtherfield instead of MyobjectTimestamp does not help either, which makes sense since all data is fetched and therefore marshaled anyway.
A similar question has been asked here, but the answer did not help me.
How can I use UTCTime in Yesod while using SQLite?
Edit:
The PersistText \"09:18:07\" that is mentioned in the error is the value the field defaulted to.
You stored a Text value "09:18:07", while it expected a UTCTime value. Did you insert values by hand?
getCurrentTime from Data.Time returns a value of type IO UTCTime, so you can either use putStr getCurrentTime in GHCI to get a valid representation, or use now <- liftIO getCurrentTime in your function.
EDIT:
Because getCurrentTime returns a timestamp like: 2013-10-25 10:16:32.1627238 UTC, inserting a value like that in your database should resolve the error.

RS-DBI driver warning: (unrecognized MySQL field type 7 in column 1 imported as character)

I'm trying to run a simple query that works with MySQL or other MySQL connector API's,
SELECT * FROM `table` WHERE type = 'farmer'
I've tried various methods using the RMySQL package and they all get the same error
RS-DBI driver warning: (unrecognized MySQL field type 7 in column 1 imported as character)
Type = 'farmer'
(Query<-paste0("SELECT * FROM `table` WHERE type = '%",Type,"%'"))
res<-dbGetQuery(con, Query)
Query<-paste("SELECT * FROM `table` WHERE type = \'farmer\'")
Query<-paste("SELECT * FROM `table` WHERE type = 'farmer'")
What am I doing wrong?
"type" is a keyword in MYSQL. Surround the it with backticks to escape field names.
SELECT * FROM `table` WHERE `type` = 'farmer'
Also you probably have a time stamp column in your table. R is known to not recognize that column type. Convert it to a unix time stamp in the portion of the SQL statement.
Looks like the db schema has something in column which is of type 7 -- and that type appears to be unknown to the RMySQL driver.
I try to exclude column one in the query, or cast it at the select * ... level eg via something like
select foo as character, bar, bim, bom from 'table' where ...
To be clear, when I encountered this error message, it was because my data field was a time stamp.
I verified this by changing my query to SELECT created_at FROM ... which caused the error. I also verified this by changing the query not to include the column names that were timestamps, then I had no errors.
Note too, that the error message counts columns starting from 0 (instead of 1 as R does)
IMHO, the answer is you aren't doing anything wrong, but it's something that needs to be fixed in RMySQL.
The workaround is after you read in your data, you need to call one of the several possible character to datetime conversion functions. (Which one depends on what you want to do with the time stamp exactly.)

Resources