I want to run a ingestion script in kusto with a condition, like:
let table_count = T | count
if (table_count > 0) { ingest ('aaa.csv') }
Anyone can help on this?
I have no idea on this
Related
I'm trying to summarize the count of exceptions, the count of requests, and then the ratio of exceptions / requests. I can't determine how to calculate the two summaries and then project the ratio and return it. I'm trying something along the following without success:
let exceptionCount = exceptions
| where type == "ShiftDigital.InventoryServices.API.GetVehicleException" and outerMessage !contains("Invalid zip code")
| count as ExceptionCount;
requests
| count as RequestCount
| extend RequestCount / exceptionCount
Can someone please advise on the correct way to structure this query?
You're missing toscalar()
let exceptionCount = toscalar(exceptions
| where type == "ShiftDigital.InventoryServices.API.GetVehicleException" and outerMessage !contains("Invalid zip code")
| count);
let requestsCount = toscalar(requests
| count);
print requestCount * 1.0 / exceptionCount
I have a requirement where I have to set collection to the existing documents. The thing is I have around 20 million records. I am running below query from query console. It is throwing time out error.
I also tried out limit=N option in below query. At max I was able to achieve N=40000, after that it's again throwing time out error.
Please help me with any faster query or approach.
for $each in cts:uri-match("/data/employee/*")
return xdmp:document-set-collections($each, "employee")
ml-gradle has OOTB support for this, no code needed. See https://github.com/marklogic-community/ml-gradle/wiki/DMSDK-Tasks#trying-it-out and look at "mlAddCollections".
Batching is the right option to perform this type of task. Use xdmp:spawn-function() function to put multiple tasks at a time on the task server. You just need to indentify the number of records which your query can finish within 10 minute or 1 hr as you required.
For example, if query can execute 5000 records within 10 minute:
let $total-records := xdmp:estimate(collection())
let $batch-size := 5000
let $pagination := 0
for $records in 1 to fn:ceiling($total-records div $batch-size )
let $start := fn:sum($pagination + 1)
let $end := fn:sum($batch-size + $pagination)
let $_ := xdmp:set($pagination, $end)
return
xdmp:spawn-function
(
function(),
for $each in cts:uri-match("/data/employee/*")[$start to $end]
return xdmp:document-set-collections($each, "employee")
)
I'm new to R, I'm trying to use 'like' command inside R query but its throwing error...i'm attaching the code , please be kind enough to rectify the same...
let from i am passing med= ABC from API end..
med_aff1<- function(med,sex)
{
affModel <- dbGetQuery(jdbcConnection ,
"SELECT * from XYZ WHERE MEDICINE %LIKE% %'",med,"'% AND SEX ='",M,"')
return(affModel)
}
I have a question regarding on how to retrieve the records that I have selected in a form, to a report.
Currently, I am able to select multiple records, but when it comes to the report, it keep on processing the same value. However the number of the records that it processed is correct, only the value is repeating.
I am not sure on how to fix this, therefore your help is kindly appreciated.
Below is the part that i get the record:
if (element.args() && element.args().dataset())
{
switch(args.dataset())
{
case tablenum(LedgerJournalTrans) :
ledgerJournalTrans = element.args().record();
info(ledgerJournalTrans.Voucher);
break;
case tablenum(LedgerJournalTable) :
ledgerJournalTable = args.record();
break;
}
}
The element.args().record() only points to the last selected record. Its datasource comes to rescue. The usual approach to process multi-selected records applies:
Common record;
FormDataSource fds;
fds = element.args().record().dataSource();
for (record = fds.getFirst(1) ? fds.getFirst(1) : fds.cursor(); record; record = fds.getNext())
{
// Do the printing using record
}
You often see this approach used in main methods of functions capable of processing multi-selected records.
The FormLetter.getFormRecord uses this pattern as well.
I'm using SQLite version 3 to run the following code.
//Run SQL SELCT query
sqlite3_prepare16_v2("SELECT * FROM table_name");
sqlite3_step();
//Need to review results in several iterations
for(int i = 0; i < n; i++)
{
//Seek to beginning
sqlite3_reset();
do
{
//Get values
sqlite3_column_int();
...
sqlite3_column_text16();
}
while(sqlite3_step() == SQLITE_ROW);
}
But for some reason the first batch of data I get is all 0's. What am I not doing correct in the code above?
Assuming what you are showing is pseudocode since you're missing many arguments to the sqlite3 funcitons...
You need a sqlite3_step after sqlite3_reset and before getting the first row of values.
You can change your do {...} while(sqlite3_step() == SQLITE_ROW) to a while(sqlite3_step() == SQLITE_ROW)...} to accomplish that.
This will also eliminate the need to step immediately after the sqlite3_prepare16_v2