#10 - Create Crypto Table- BR- Transform Map and Load Historical Data.
hello everyone so in this video we are going to create our crypto table then a business rule then a transform map then also we are going to load our data into our staging table using our data source and after that we will run our transform map in order to transfer the data from our staging table to our target table and finally we will disactivate the transformer okay so let's create now the uh crypto table so i'm gonna click on create application file make sure that you have table here click on create and then i'm gonna name it for example here crypto i don't need a module so i'm gonna unselect that one make sure that you select your order number column i'm gonna have three columns the first one i'm gonna have coin and that's going to be a reference field and it will refer the core coin table that we have created in the beginning okay so the second field is going to be the price field and the type i'm going to have it here alone and the third field i'm gonna have the date and the type here is date and date time okay so click on submit okay so this is not good here okay so make sure uh one of the field here for example the number field i'm gonna have the display value to set to true and then save again great so now we have our crypto table let's uh see the list view and we have the number coin date and price i'm going to add two more fields created and then updated okay um we are going to write a business rule now and then we have to uh make sure that the date that i'm going to have here in the created field it should be uh the same day that we have in the date field okay i don't want to have here today's date if i'm importing data for today so for that i'm going to create a business rule so look for business rule here click on create let's give it a title up date created and updated field value okay the table is going to be crypto table okay and then i'm going to click on advanced then to run we are going to have a before business rule before an insert we are going to run this business rule and the order should be 100 okay this is highly important and then the action i'm going to have here created field we'll have the same value as the date field and we do the same for updated field okay this is how we we are making sure that we have the same date here in the created field and the updated field so click on submit great so we have our business rule as well so let's create now our transfer map so i'm going to look for transfer map here click on transfer map sorry click create let's give it a name here i'm gonna give here historical [Music] data transform map okay the source table is the uh coin table sorry coin history table and here i'm gonna have crypto table that's our target table and the order should be 200 we have already our business rule which is 100 the order that we have for our business rule and we should run the business rule first and then the transformer click on submit and click on auto map matching fields so we have we got two fields mapped here price and date and we are we need also the uh coin field okay and in our so stable the coin field is this one name and here i have coin so click on save so we have mapped all our fields but one thing that we have to do also is the date field um we are not actually getting a date from the request we have um index time so if you go let me show you quickly let's go here and then just click on this uh link and you have the respond json response for a bitcoin sorry probably you're not seeing this screen so let me just copy this and put this json person online and now you can see this is the index time okay this is what we get but even it is like 1 1.4 and e something that's what we get okay that's the string that we get so we need to write a script in order to convert and then have a the proper date format okay so let's start to write our script the first thing i'm going to do i'm in the script background i'm going to create okay i'm changing my string into a float value okay you can use parse int but for some reason it is not changing uh it is not putting the proper date so i prefer to use here parse float and uh this is kind of one of the value that we get so i'm gonna just take here so if you want to see these values you can basically go to your source table let me show you and then click on show list pick this import set then you can pick any record see here this is the date that we get okay so let's go back to our script script background so this is the first thing and let's see if we do js info what we get as value okay jsinfo time okay you can see here i have number and then some zeros great so let's continue with our code the second thing we are going to do we are going to create a variable j d t it's a glide daytime variable so i'm going to have write it like this glide date time okay then we are going to have a specific method which is actually going to have as input the time here the time value which we have like um which we converted i mean which is a float now and it will allow us to have the proper time later which means we can have the years months and days so on so what we have to do we have to write j sorry j dt dot set numeric value okay so in the parameters we should have a value in milliseconds okay so that's going to be our time and basically this method is actually calculating a time millisecond from first of january uh 1970 something like this and i think that's all we need to know at this point and then we can now actually create a new variable i'm going to call it val date equal to use gdt variable and then i'm going to get value so we will have our date in a proper format okay like this so if i do gs info date i should have a date now you can see here i have 18 i don't know 6 2020. so we have our script so let's just copy everything that we have here go to our transform map click on any date you underscore date and then click on use source script and just delete this part and put the code right here so we cannot have value all the time we i mean we have to have a field here which is actually going to give us the date so the fuel we are looking for here is source dot u underscore date okay so i'm going to return the date value so it is going to have finally we will have this format so year month day hour minutes and seconds so let's save this one great so we are done with pretty much everything now we have to make sure one thing which is if i go back to my file sheet here and click on script let's zoom a little bit so every day the length for our coins it is changing okay so for today i checked uh and i have these values okay 1825 some of them will have a little bit different value it's not the same value that i had every day yesterday sorry and the total here is 11 846 okay so once um once you have uh have the right values make sure you have the right values also here okay these are the length that we should update in our script in flow designer that is absolutely important here so we can get all the data so now what we need to do is to load our data into our staging table and make sure that we have this number okay so let's go back here and then click on coin history details data source okay let me just check if my transform app it is properly updated with the script great so i have script here okay so so it's not showing us the script now okay let's click one more in the data source here okay so i'm going to click on load all records and and let's store all the cars into our staging table okay so as you can see here we have 11 846 that's the number of the records that we should have in our staging table that's the number that we have here okay so let's click now run transform and we should have a historical transform map here on the right side so you can see a historical data transfer map that's the one that we have we don't have the other map because we have this activated right so let's click on transform and it's going to actually take the data from the staging table and put it into our target table and we should have all the records the date should be correct for our date field and also for created field great so we have a completion code here success let's go see in our crypto table if you have all the data okay so let's uh let's delete this delete this date this let's go here and click on show list okay again okay so as you can see here i have uh the record the elder cards are created i have all the coins i have today's data for example here for customers the price and also the right date here in the created field so if you want to make sure that you have all the coins for today you can just click right click here click on show matching it is actually going to show you [Music] that we have uh like all the coins which were created today so you can see here we have eight as number so we have all our coins that's it so we are done with this part and in the next video we'll be working on creating our floor designer action 2 our request here and then continuing with all this stuff it is going to be extremely fast uh we don't need to write a big um a big script for that so see you in the next video thank you for watching bye
https://www.youtube.com/watch?v=OQE8CRcq49A