Changing a field from String to Int in Pentaho Data Integration - pentaho

I am taking JSON information from our online API and producing it in a table with DI. I have 4 fields url, deviceId, displacement & timestamp. These are all recorded as Strings but I want them to be Int values, bar the url.
In the Generate Rows section I tried changing each parameter to an Int but the results would not show up but if I left them as Strings, it will post the results.
Any help on how I could change the data from type String to Int and still have my data reported?

Take Select/Rename values Step, and change the data-type in meta-data section.

Related

Pentaho compare values from table to a number from REST api

I need to make a dimension for a datawarehouse using pentaho.
I need to compare a number in a table with the number I get from a REST call.
If the number is not in the table, I need to set it to a default (999). I was thinking to use table input step with a select statement, and a javascript step that if the result is null to set it to 999. The problem is if there is no result, there is nothing passed through. How can this be done? Another idea was to get all values from that table and somehow convert it to something so I can read id as an array in javascript. I'm very new to pentaho DI but I've did some research but couldn't find what I was looking for. Anyone know how to solve this? If you need information, or want to see my transformation let me know!
Steps something like this:
Load number from api
Get Numbers from table
A) If number not in table -> set number to value 999
B) If number is in table -> do nothing
Continue with transformation with that number
I have this atm:
But the problem is if the number is not in the table, it returns nothing. I was trying to check in javascript if number = null or 0 then set it to 999.
Thanks in advance!
Replace the Input rain-type table by a lookup stream.
You read the main input with a rest, and the dimension table with an Input table, then make a Stream Lookup in which you specify that the lookup step is the dimension input table. In this step you can also specify a default value of 999.
The lookup stream works like this: for each row coming in from the main stream, the steps looks if it exists in the reference step and adds the reference fields to the row. So there is always one and exactly one passing by.

access sql text not available for listbox

I have a SQL server-backed Access database, and I'm struggling with one of my tables, "Notes".
My database has a Profile form for each user, and on their profile, I want to display notes from the Notes table. My notes table is set up like this:
NoteID (PK) int
GoerID int
NoteType int
Note (????)
StaffID int
Timestamp datetime
My issue is with the Note format. I can get a query to pull all information, but when I try to use a listbox to display the query info, the Note field is NOT available to add to the listbox.
I'm sure it's likely this is due to the field type, but I've tried every type I can think of. ntext, text, nchar, etc. Basically, I need this note field to have around 200 characters of variable text and be displayed in the listbox.
Any help would be appreciated!
Thanks
Updated with screenshot of table and datatype settings in Manager Studio:
Screencap
Also note that I've rebuilt the table several times (when changing datatypes), and in the screencap, the NOTE field is actually named [NoteText]
Use varchar(255) or (if you need Unicode) nvarchar(255).
That will translate into Text(255) (resp. Short Text in newer Access versions) on the Access side, and will work with your listbox as well.

Query in Google Spreadsheet

I made a simple query function as this: =QUERY(range,"select *",1), in my Google Spreadsheet, but the results dose not show any letters, it shows only fields that contains numbers.
Study this link
Syntax
QUERY(data, query, [headers])
data - The range of cells to perform the query on.
Each column of data can only hold boolean, numeric (including
date/time types) or string values.
In case of mixed data types in a single column, the majority data type
determines the data type of the column for query purposes. Minority
data types are considered null values.
Just format your range as a plain text using Format > Number > Plain text option, the below images show how to do it:

Date in a short text data type field... Select query trouble

In my Access database, I have a table called customers. In this table I have a column called DateEntered. The data type for the field is short text.
The values in this column are not coherent - they come in several variations:
MM-DD-YYYY,
MMDDYYYY and
MM/DD/YYYY.
There doesn't seem to be any standard set.
My goal is to select all customers from 2012. I tried
select *
from customers
where DateEntered <('%2013') AND >('%2012');
but it comes up blank when I run it.
Can anyone point out what I'm failing to do correctly & more importantly explain why exactly this query doesn't work in Access? From my understanding of SQL (not very advanced) this should work.
Another variant)
select * from customers where RIGHT(DateEntered, 4) = '2012'
If you have control over the database and application code, the best way to handle this is to use an actual Date field instead of text in the table.
One way to handle this would be to add a new field to the table, write a query or two to correctly convert the text values to actual date values, and populate the new field.
At this point, you would then need to hunt down the application code the refers to this field in any way and adjust to treat the field as a date, not text. This includes your insert and update statements, report code, etc.
Finally, as a last step, I would rename the original text field (or remove it altogether) and rename the new date field to the original field name.
Once you fix the problem, querying against the field will be a piece of cake.
Alternatively, if you can't alter the table and source code, you can use the date conversion function CDATE() to convert the text value to an actual date. Note that you may need to guard against non-date entries (NULL or empty string values, as well as other text values that aren't really dates in the first place). The IsDate() function can be your friend here.
If you have the time and patience, fixing the data and code is the better approach to take, but sometimes this isn't always feasible.
Why don't you use LIKE operators (they're appropriate when you have a pattern using % and _):
select * from customers where DateEntered like '%2013' or DateEntered like '%2012'

SSRS report not displaying data

I have just created an SQL Server 2005 SSRS report and the data is not being displayed in the Preview pane.
The dataset is correctly populated from a stored procedure against a String parameter. I can execute it in the Data pane. When running the report in the Preview pane the correct number of rows are displayed but the contents of the cells do not contain any data
The source dataset is based on a Stored Procedure with a passed in String parameter in SQL Server 2005 that return the contents of a temp table. The dataset then maps the fields to locals. I can execute this correctly in teh Data view.
Stored Procedure
ALTER PROCEDURE spWebReportStage25BuildReview
#BuildNumber as nvarchar(50)
Temp table schema
CREATE TABLE #tmpModelZones
(
BuildID bigint NOT NULL,
BuildNo nvarchar(50) NOT NULL,
ModelID int NOT NULL,
ModelName nvarchar(50) NOT NULL,
ZoneID int NOT NULL,
ZoneName nvarchar(50) NOT NULL,
SortOrder int NOT NULL,
Created bit DEFAULT 0 NOT NULL,
Closed bit DEFAULT 0 NOT NULL,
PRIMARY KEY (BuildID, ZoneID)
)
SSRS Dataset
SSRS Dataset mapping
SSRS Dataset Parameter
Executing Dataset with parameter
There are no additional grouping, filters or aggregation on the displayed table. It is simply a flat table
Never seen this before. However, SSRS can be a bit "off" at times, so here's a list of things to try. I'm afraid most of these are of the type "Have you tried turning it off and on again?".
Delete the .data files associated with the report.
Duplicate/back-up the report, and try to add the dataset in a fresh, basic tablix to see if that does show data.
Check the hidden property. Don't forget that (for some stupid reason) it's not (like in any other sane product) a Visible Y/N field, but a Hidden Y/N field.
Double check font color and size, etc.
Run the report on your reportserver (as opposed to the preview) to check if that does work.
Use some temporary text boxes to show the actual values of your parameters, to check if they are exactly the same as when you test-run the data set.
Check the code-behind (xml in the rdl) for unexpected filters, hidden property, expressions, etc. in the tablix. Even if you can't quite "read" the RDL, with syntax highlighting you should be able to skim it and extract a lot of info on this.
Check the ExecutionLog2 and other logging stuff to see how many rows are being returned in report runs.
In addition, it would help if you update/edit your question with some more info:
What kind of groupings does the tablix have?
What are the filters on the tablix, row groups, and column groups?
What is the general structure of the dataset, and it's results?
How are the parameters structured and used?
When using temporary tables, SSRS fails to get the metadata. So there are basically 2 ways of letting SSRS know the column names:
Add SET FMTONLY ON. This will retrieve the metadata but it won't display the data.
Go to the DATA tab and click on the Generic query designer and click refresh fields. This will prompt a dialogue box for specifying the parameter value. When we run the query in query designer SSRS gets the schema and the data from the stored procedure. Now the data will be available in preview pane.
I also had a similar issue. In my case, it even occurred without any parameters or anything, just the most simple report you can imagine. It included a table with a single field, no filters were used. I did manage to view some data, but only those lines were shown which did not fit into the cell and thus forced the row height to increase.
My fix for this issue: changing the font or the font size from the standard (size 10, Segoe UI). Then, all data was showing. Changing this back to Segoe UI made the data disappear once again.
I had the same problem. Here is what I found. Here is my code:
DECLARE #tblPigProblems TABLE (
Id INT IDENTITY,
PPId INT,
GaugeColor VARCHAR(25),
FullStartTime VARCHAR(25),
PigSystem VARCHAR(25)
)
IF (1 = 0)
BEGIN
SELECT * FROM #tblPigProblems
END
...
SELECT '#tblPigProblems' [PigProblems],
#p_vchLine [Line],
GaugeColor [Product],
FullStartTime [Start Time],
PigSystem [Pig System]
FROM #tblPigProblems
What I did was to use the initial "SELECT * FROM #tblPigProblems" to ensure that if any error messages were specified in the code before the final select statement returning the dataset, that SSRS was able to determine the fields from the stored procedure. Then, when the results were determined, I assigned an alias to the fields. The problem was that the aliases for the fields did not match the declared field names (ie: the declared field "GaugeColor" did not match the alias "[Product]" I supplied in the select to create the result set. The way that I realized this is that when I refreshed the fields in the Data section of the SSRS report, then displayed the dataset fields, it listed the field names from the table declaration (ie: "GaugeColor"). When I executed the stored procedure within the dataset (clicked on the !), the result set listed in SSRS showed the field aliases (ie: "Product"). Since these didn't match, nothing was displayed in the textbox I had assigned the field to (ie: "=Fields!ColorGauge.Value"). SSRS did not pick up this discrepancy and allowed the report to be created, but no values to be displayed. The fix was simple, replace:
IF (1 = 0)
BEGIN
SELECT * FROM #tblPigProblems
END
with:
IF (1 = 0)
BEGIN
SELECT '#tblPigProblems' [PigProblems],
#p_vchLine [Line],
GaugeColor [Product],
FullStartTime [Start Time],
PigSystem [Pig System]
FROM #tblPigProblems
END
Dan
I had a case where a working report stopped displaying data. I added another table with no formatting, linked to same dataset - verified that the query no longer returned data when passed parameters by SSRS. After investigating, I noticed that my test parameter for a "anchor date" value was formatted as YYYY-MM-DD, and in my updated query, I was making assumptions about the order of the characters in the date parameter (to truncate to YYYY-MM for one join).
I suspected that SSRS may be passing the date in a different format (MM/DD/YY being my current cultural setting for date defaults). So running with that hunch, I changed my SQL logic to work with any date format passed. - e.g. left(convert(date, #anchorDate, 20), 7)
This fixed my problem - the format assumptions that I had tested with (hard coded values to test the query while developing) were bad assumptions. SSRS can pass data in local formats as well - so be sure to watch out for this kind of assumption.
I had the same problem and I tried to check the priorities of my tablix. I solved the problem by changing CANGROW value to FALSE.