I try to run this query
delete from bucket o
use keys (select raw ARRAY_CONCAT(ARRAY_CONCAT(ARRAY_CONCAT(d, t), s), u)
from bucket
use keys 'SS')
I get this response:
{
"status": "Unexpected server error"
}
in the server log I see this:
Service 'query' exited with status 1. Restarting. Messages: runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc20e97cfc0 sp=0xc20e97cfb8
created by github.com/couchbase/query/parser/n1ql.NewLexerWithInit
/home/couchbase/jenkins/workspace/watson-unix/goproj/src/github.com/couchbase/query/parser/n1ql/n1ql.nn.go:30999 +0x4a6c9
[goport] 2016/11/29 08:40:11 /opt/couchbase/bin/cbq-engine terminated: signal: aborted (core dumped)
What the problem with this query?
I am using couchbase version 4.5.
you can also use ARRAY_FLATTEN() function or the FIRST operator.
delete from bucket o use keys
ARRAY_FLATTEN( ( select raw ARRAY_CONCAT(ARRAY_CONCAT(ARRAY_CONCAT(d, t), s), u) from bucket use keys 'SS'), 1)
returning meta(o).id;
or
delete from bucket o
use keys FIRST x FOR x IN
( select raw ARRAY_CONCAT(ARRAY_CONCAT(ARRAY_CONCAT(d, t), s), u)
from bucket
use keys 'SS' )
END
returning meta(o).id;
Note that parenthesis (in bold italics) is required around the sub-query when it is used as expression (for example, as parameter to ARRAY_FLATTEN() or in the FIRST construct)
USE KEYS requires array of keys. ARRAY_CONCAT() returns array and Subquery returns array. It become array of array.
Remove one of the array as follows.
delete from bucket o
use keys (select raw ARRAY_CONCAT(ARRAY_CONCAT(ARRAY_CONCAT(d, t), s), u)
from bucket
use keys 'SS')[0];
If the ARRAY_CONCAT() argument is missing or null, it may return same panic error in 4.5. This has been fixed in 4.5.1.
Related
x = fopen('pm10_data.txt');
fseek(x, 8,0);
dat = fscanf (x,'%f',[2,1000]);
dat = transpose(dat);
a = dat(:,1);
b = dat(:,2);
[r,p] = cor_test (a,b)
fclose(x);
r
p
this is what i got,
r =
scalar structure containing the fields:
method = Pearson's product moment correlation
params = 76
stat = 6.2156
dist = t
pval = 2.5292e-08
alternative = !=
Run error
error: element number 2 undefined in return list
error: called from
tester.octave at line 7 column 6
Presumably you're referring to the cor_test function from the statistics package, even though you don't show loading this in your workspace.
According to the documentation of cor_test:
The output is a structure with the following elements:
PVAL The p-value of the test.
STAT The value of the test statistic.
DIST The distribution of the test statistic.
PARAMS The parameters of the null distribution of the test statistic.
ALTERNATIVE The alternative hypothesis.
METHOD The method used for testing.
If no output argument is given, the p-value is displayed.
This seems to be what you're getting too.
If you want the p value explicitly from that structure, you can access that as r.pval
The syntax [a, b, ...] = functionname( args, ... ) expects the function to return more than one argument, and capture all the returned arguments into the named variables (i.e. a, b, etc).
In this case, cor_test only returns a single argument, even though that argument is a struct (which means it has fields you can access).
The error you're getting effectively means you requested a second output argument p, but the function you're using does not return a second output argument. It only returns that struct you already captured in r.
I am using hibernate core 5.4.33.Final, and mysql-connector 8.0.22.
DB MySql org.hibernate.dialect.MySQLDialect.
My problem occurs on previous release too.
Running a simple SQL query on a single table, no join, returns only last record for n times, where n is the correct records number.
HQL Query
SELECT ig.id, ig.codice
FROM ImpiantiGestitiDto as ig
Schema:
id=integer autoincrement
idPalestra=integer
codice=varchar(6)
numero=char(3)
codice_descrizione_impianto=varchar(6)
ImpiantiGestitiDto=Dto
This is my code. I don’t use loop.
Query<Object> query = session.createQuery(hql);
result = query.getResultList();
The mysql-connector run the query succesfully:
StandardRowReader - ---Processing Row---
Extracted JDBC value [0] - [1]
Extracted JDBC value [1] - [000.00]
StandardRowReader - ---Processing Row---
Extracted JDBC value [0] - [2]
Extracted JDBC value [1] - [000.01]
StandardRowReader - ---Processing Row---
Extracted JDBC value [0] - [3]
Extracted JDBC value [1] - [000.02]
StandardRowReader - ---Processing Row---
Extracted JDBC value [0] - [4]
Extracted JDBC value [1] - [000.03]
Output on getResultList(); Wrong!
[[4,"000.03"],[4,"000.03"],[4,"000.03"],[4,"000.03"]]
I think the problem occurs in:
-org.hibernate.sql.results.spi package;
-class ListResultsConsumer;
-method Consume.
in following loop, results.add(row) ; instructions occurs the error.
Why occurs the problem? Can you help me? Thank you!
while (rowProcessingState.next()) {
final R row = rowReader.readRow( rowProcessingState, processingOptions );
boolean add = true;
if ( uniqueRows ) {
if ( results.contains( row ) ) {
add = false;
}
}
if ( add ) {
results.add( row );
}
rowProcessingState.finishRowProcessing();
}
Using the query
FROM ImpiantiGestitiDto order by id
it’s works.
Using the query
SELECT id, codice FROM ImpiantiGestitiDto order by id
does not work.
I have to use the second query because the table ImpiantiGestitiDto is joined to another table and I have to use the WHERE clause.
Thanks for your answer.
I have a table in Bigquery which has 2 columns - job_id and json_column(string which is in JSON format). When I tried to read the data and identify some objects it gives me error as below:
SyntaxError:Unexpected end of JSON input at undefined line XXXX, columns xx-xx
It Always gives me line 5931 and second time I execute again it gives line 6215.
If it's related to JSON structure issue, how can I know which row/job_id that number 5931 corresponds to? If I subset for a specific job_id, it returns the values but when I tried to execute on the complete table, I got this error. I tried looking at the job_id at the row_numbers mentioned and code works fine for those job_ids.
Do you think its JSON structure issue and how to identify which row/job_id has this Issue?
Table Structure:
Code:
CREATE TEMPORARY FUNCTION CUSTOM_JSON_EXTRACT(json STRING, json_path STRING)
RETURNS ARRAY<STRING>
LANGUAGE js AS """
var result = jsonPath(JSON.parse(json), json_path);
if(result){return result;}
else {return [];}
"""
OPTIONS (
library="gs://json_temp/jsonpath-0.8.0.js"
);
SELECT job_id,dist,gm,sub_gm
FROM lz_fdp_op.fdp_json_file,
UNNEST(CUSTOM_JSON_EXTRACT(trim(conv_column), '$.Project.OpsLocationInfo.iDistrictId')) dist ,
UNNEST(CUSTOM_JSON_EXTRACT(trim(conv_column), '$.Project.GeoMarketInfo.Geo')) gm,
UNNEST(CUSTOM_JSON_EXTRACT(trim(conv_column), '$.Project.GeoMarketInfo.SubGeo')) sub_gm
Would this work for you?
WITH
T AS (
SELECT
'1000149.04.14' AS job_id,
'{"Project":{"OpsLocationInfo":{"iDistrictId":"A"},"GeoMarketInfo":{"Geo":"B","SubGeo":"C"}}}' AS conv_column
)
SELECT
JSON_EXTRACT_SCALAR(conv_column, '$.Project.OpsLocationInfo.iDistrictId') AS dist,
JSON_EXTRACT_SCALAR(conv_column, '$.Project.GeoMarketInfo.Geo') AS gm,
JSON_EXTRACT_SCALAR(conv_column, '$.Project.GeoMarketInfo.SubGeo') AS sub_gm
FROM
T
BigQuery JSON Functions docs:
https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions
how can I read multiple arrays in an object in JSON without using
unnest?
Can you explain better with an input sample your comment?
I have the below string in a column in hive table which i am trying to query using apache drill:
{"cdrreasun":"52","cdxscarc":"20150407161405","cdrend":"20150407155201","cdrdnrar.1un":"24321.70","servlnqlp":"54.201.25.50","men":"42403","xa:lnqruup":"3","cemcau":"120","accuuncl":"21","cdrc:
5","volcuca":"1.7"}
Want to retrieve all values for key cdrreasun using apache drill SQL.
Can't use FLATTEN on the column as it says Flatten does not work with inputs of non-list types.
Can't use KVGEN as well as it works only with MAP datatype.
Drill has function convert_fromJSON which allows converting from String to JSON object. For more details about this function and examples of usage please see https://drill.apache.org/docs/data-type-conversion/#convert_to-and-convert_from
For the example you specified, you can run
convert_fromJSON(colWithJsonText)['cdrreasun']
I figured it out, hope it will be helpful for others.
We have to do it in 3 steps if the datatype is of type MAP:
KVGEN() -> FLATTEN() -> convert_from()
If it's of type STRING then KVGEN() function is not needed.
SELECT ratinggrouplist
,t3.cdrlist3.cdrreason AS cdrreason
,t3.cdrlist3.cdrstart AS cdrstart
,t3.cdrlist3.cdrend AS cdrend
,t3.cdrlist3.cdrduration AS cdrduration
FROM (
SELECT ratinggrouplist, convert_from(t2.cdrlist2.`element`, 'JSON') AS cdrlist3
FROM (
SELECT ratinggrouplist ,flatten(t1.cdrlist1.`value`) AS cdrlist2
FROM (
SELECT ratinggrouplist, kvgen(cdrlist) AS cdrlist1
FROM dfs.tmp.SOME_TABLE
) AS t1
) AS t2
) AS t3;
It is possible to preserve insertion order when parsing a JSON struct with a
Poco::JSON::Parser( new Poco::JSON::ParseHandler( true ) ): the non-default ParseHandler parameter preserveObjectOrder = true is handed over to the Poco::JSON::Objects so that they keep an private list of keys sorted in insertion order.
An object can then be serialized via Object::stringify() to look just like the source JSON string. Fine.
What, however, is the official way to step through a Poco::JSON::Object and access its internals in insertion order? Object::getNames() and begin()/end() use the alphabetical order of keys, not insertion order -- is there another way to access the values, or do I have to patch Poco?
As you already said:
Poco::JSON::ParseHandler goes into the Poco::JSON::Parser-constructor.
Poco::JSON::Parser::parse() creates a Poco::Dynamic::Var.
From that you'll extract a Poco::JSON::Object::Ptr.
The Poco::JSON:Object has the method "getNames". Beginning with this commit it seems to preserve the order, if it was requested via the ParseHandler. (Poco::JSON:Object::getNames 1.8.1, Poco::JSON:Object::getNames 1.9.0)
So now it should work as expected to use:
for(auto const & name : object->getNames()){
auto const & value = object->get(name); // or one of the other get-methods
// ... do things ...
}