DataLake Analytics USQL : Failed to compare two elements in the array - azure-data-lake

I created a Database in Data lake Analytics.
Then populated with data from files in my data lake.
When I then query the table I have made, I have some success, but some strange errors.
(Strange to me !)
This works: WHERE [Stamped Serial number] == "000074O1"
This does not: WHERE [CTN Number] == "000074-1"
Error :
"A system failure has occurred during code generation. Failed to
compare two elements in the array."
Both fields are strings, so I'm not sure what the difference is.
One (the failing one) is also part of my index & distribution - but I'm lost if that is anything to do with my problems.
All the code for table def, populating and final queries are below.
If anyone can help me understand what I am doing wrong ... !?
... will be extremely grateful :)
Script: Create Table
CREATE TABLE IF NOT EXISTS Play.RawData
(
[CTN Number] string
,[SeqNo] long
,[UTC Time Stamp for Event] string
,[Biz step Description] string
,[Stamped Serial number] string
,[Container Status] string
< -- more columns -- >,
INDEX
idx_CTN CLUSTERED ([CTN Number],[SeqNo])
DISTRIBUTED BY HASH ([CTN Number],[SeqNo])
);
Script: Populate Table
DECLARE #dir string = "/myDataPath/";
DECLARE #file_set_path string = #dir + "File_{date:yyyy}{date:MM}{date:dd}.DAT";
#results_1 =
EXTRACT
[CTN Number] string
,[UTC Time Stamp for Event] string
,[Biz step Description] string
,[Stamped Serial number] string
,[Container Status] string
< -- more columns -- >,
,date DateTime // virtual file set column
FROM #file_set_path
USING Extractors.Tsv();
INSERT INTO Play.RawData(
[CTN Number],
[SeqNo],
[UTC Time Stamp for Event],
[Biz step Description],
[Stamped Serial number],
[Container Status],
< -- more columns -- >
)
SELECT
[CTN Number],
ROW_NUMBER() OVER(PARTITION BY [CTN Number] ORDER BY [UTC Time Stamp for Event] ASC) ?? -1 AS [SeqNo],
[UTC Time Stamp for Event],
[Biz step Description],
[Stamped Serial number],
[Container Status]
FROM #results_1
WHERE
date >= DateTime.Parse("2013-01-01")
AND
date < DateTime.Parse("2013-02-01");
Script: Test Query
#table =
SELECT [UTC Time Stamp for Event],
[Biz step Description],
[CTN Number],
[Stamped Serial number]
FROM [CTN].[Play].[RawData]
WHERE
//[Stamped Serial number] == "000074O1";
[CTN Number] == "000074-1";
OUTPUT #table
TO "/output/results.tsv"
USING Outputters.Tsv(outputHeader:true);

This looks like a bug to me. Can you please send me a link to the failed job at usql (at) microsoft dot com?
Thanks
Michael

Related

SQL Execution error while running parameter query

Can somebody tell me what i have done wrong in my Parameter query as it does not work?
Basically my intention is to create a search result and display it using DataGridView.
These errors appear when I click 'Execute Query' on query builder window.
Below is the SQL Statement
SELECT Products.[Product Name], Products.[Product code], [Brands For Sales].[Brand Name], [Main Group].[Group Name], Category.[Catogory Name], SubCatogory.[SubCatogory Name]
FROM (((((Products INNER JOIN
Category ON Products.[Category-ID] = Category.ID)
INNER JOIN
[Brands For Sales] ON Products.[Brand Name] = [Brands For Sales].ID) INNER JOIN
[Main Group] ON Products.[Group-ID] = [Main Group].ID AND Category.[Group-ID] = [Main Group].ID) INNER JOIN
Category Category_1 ON Products.[Category-ID] = Category_1.ID AND [Main Group].ID = Category_1.[Group-ID]) INNER JOIN
SubCatogory ON Products.[SubCategory-ID] = SubCatogory.ID AND Category.ID = SubCatogory.[Catogory-ID] AND Category_1.ID = SubCatogory.[Catogory-ID])
WHERE (Products.[Product Name] LIKE '%' + #Searchbox + '%')
If I remember correctly, Query Builder doesn't support named parameters even for SQL Server, never mind Access. Replace each of your #ParameterName placeholders with ? and you should be good to go.
EDIT:
The only thing that changes when using positional parameters rather than named parameters (other then the fact that you must add them in the same order as they appear in the SQL, which you should do anyway) is that you cannot reuse a parameter. That means that you might have to pass the same value twice. For instance, if you used this SQL with named parameters:
SELECT *
FROM MyTable
WHERE Column1 = #SomeValue
OR Column2 = #SomeValue
and then you passed a single value to a single parameter to be used twice in the SQL code, you would change the SQL to this with positional parameters:
SELECT *
FROM MyTable
WHERE Column1 = ?
OR Column2 = ?
and then your command would have two parameters and you would pass the same value to both of them. That's exactly what everyone already does with Access even if they do name their parameters, because the Jet and ACE OLE DB providers ignore those names and use positions anyway.

Error in list of function arguments: '>' not recognized. Unable to parse query text

I have a query like below in sql server, when i use it in the new query window it has no syntax error and it is executed but when i use it in a view and right click on it for changing design, it has below syntax error but any way it is executed and shows records.
Error in list of function arguments: '>' not recognized.
Unable to parse query text.
SELECT tblDocuments.[Project No],
tblDocuments.Originator,
tblDocuments.Zone,
tblDocuments.Unit,
tblDocuments.Discipline,
tblDiscipline.DiscDesc,
tblDocuments.[Document Type],
tblDocuments.[Owner Document Number],
tblDocuments.[Sazeh Document Number],
tblDocuments.[IDENTIFICATION CODE1],
tblDocuments.[IDENTIFICATION CODE2],
tblDocuments.[Document Title],
tblDocuments.SheetNumber,
CHARINDEX('(', [tblTransmittals].[Owner Document Number]) - 1 AS Doc_Visual_pos,
IIF(CHARINDEX('(', [tblTransmittals].[Owner Document Number]) - 1 > 0, LEFT([tblTransmittals].[Owner Document Number], CHARINDEX('(', [tblTransmittals].[Owner Document Number]) - 1), [tblTransmittals].[Owner Document Number]) AS Doc_Visual,
tblTransmittals.REV,
tblTransmittals.POI,
tblPurposeofIssue.[Purpose of Issue Description],
tblTransmittals.CC,
tblTransmittals.[Int-Tr-NO],
tblTransmittals.[To-Owner-Tr-No],
tblTransmittals.[MC-CSheet-No],
tblTransmittals.AcCode,
tblTransmittals.Pages,
tblTransmittals.PaperSize,
tblTransmittals.SJC_TO_MC_Let_NO,
tblTransmittals.MC_TO_SJC_Let_No,
tblTransmittals.To_FEng_Tr_No,
tblTransmittals.SJC_Tr_No,
tblTransmittals.Ext_Int,
tblTransmittals.[Early Planned Issue Date],
tblTransmittals.[Late Planned Issue Date],
tblTransmittals.[Tag-No],
tblTransmittals.Phase,
tblTransmittals.SubPhase,
tblTransmittals.ActivityID,
tblTransmittals.Manhour,
tblTransmittals.WorkPackage,
tblTransmittals.[DCN-No],
tblTransmittals.[DCR-No],
tblTransmittals.[DCR-Reason],
tblTransmittals.Remark,
tblTransmittals.LastRevPerDoc,
tblTransmittals.LastRevPerPOI,
tblTransmittals.HoldBy,
tblTransmittals.CommentID,
tblTransmittals.ExTrID,
tblTransmittals.HT_TR_No,
tblTransmittals.Recipients,
tblTransmittals.MC_HD_Comment_No,
tblTransmittals.[CT- Transmittals],
tb_CT_CS_transmittalNo.[CT_CS_Tr-Date],
tblTransmittals.DefaultForDocument,
tblTransmittals.HyperDoc,
tblTransmittals.root
FROM tb_CT_CS_transmittalNo
RIGHT JOIN(((tblDocuments
LEFT JOIN tblTransmittals ON tblDocuments.[Owner Document Number] = tblTransmittals.[Owner Document Number])
LEFT JOIN tblPurposeofIssue ON tblTransmittals.POI = tblPurposeofIssue.[Purpose of Issue])
LEFT JOIN tblDiscipline ON tblDocuments.Discipline = tblDiscipline.DiscCode)ON tb_CT_CS_transmittalNo.CT_CS_Tr_No = tblTransmittals.[CT- Transmittals]
WHERE tblTransmittals.Remark_Doc <> 'Deleted'
OR tblTransmittals.Remark_Doc IS NULL;
i would like this does not show this syntax error when i want to change design of view.

Two nearly identical Access queries, one gives 'Invalid procedure call'

This runs correctly:
select [feature number],
len(mid([feature number],instr([feature number],"."))) > 2 from featuredata
This gives an Invalid procedure call error:
select [feature number] from featuredata
where len(mid([feature number],instr([feature number],"."))) > 2
feature number is a Text field, but even when I prevent non-numeric values from being processed:
select [feature number] from featuredata
where iif(isnumeric([feature number]),
len(mid([feature number],
instr([feature number],"."))) > 2,false)
I still get the Invalid procedure call error. Why am I getting this error?
What happens is this:
If instr([feature number],".") is 0, then you call
mid([feature number], 0) , and this is invalid.
You shouldn't check for isnumeric([feature number]) in your iif, but for
instr([feature number],".") > 0
Edit: Why does the first version run?
While it runs, it should return #Function! for every row where there is no "." in [feature number]. So the error happens here too.

Conversion failed when converting the nvarchar value 'CIS100 ' to data type int

Can somebody help me? I'm trying to run a count command so it counts all of the students that are in each class number so I'm running this command. Although I'm getting this error.
Conversion failed when converting the nvarchar value 'CIS100 ' to data type int
Here's my SQL Query
USE RMUDB
GO
SELECt *
FROM Class
WHERE [Class Number] = (Select Count([Class Number]) FROM Enrollment)
If you want to count the students in each class, doesn't the following query do what you want?
SELECT c.[Class Number], COUNT(e.[Class Number])
FROM Class c LEFT JOIN
Enrollment e
ON c.[Class Number] = e.[Class Number]
GROUP BY c.[Class Number];
Your query is comparing the result of a counting operation (an integer) to [Class Number], which is the name of something. It is unlikely that = makes sense.

take numeric values from text

i have values such as
1st
2nd
3rd
4th
how would use an sql statement to just take the numbers and put them in a table so that i just have 1,2,3,4
right now i am trying this code below
DoCmd.RunSQL "UPDATE DEDValidation LEFT JOIN ReqInput ON DEDValidation.[Plan Code] = ReqInput.[Plan Code] SET DEDValidation.[Expected Plan Effective Day] =ReqInput.[Start Day] WHERE DEDValidation.[DED Row Found] = 'Yes'"
DoCmd.RunSQL "Update DEDValidation Set DEDValidation.[Expected Plan Effective Day] = REPLACE(DEDValidation.[Expected Plan Effective Day], '*st', '') WHERE DEDValidation.[Expected Plan Effective Day] LIKE '*st'"
the first line imports the code and the second is supposed to replace the letters 'st' with a blank, but its not working
Try this. Change the Replace function for this:
REPLACE(DEDValidation.[Expected Plan Effective Day], 'st', '')
Hope it helps you!