Related
I am querying data from a internally stage file in snowflake as below -
I get the following error:
SQL compilation error: Format argument for function 'TO_TIMESTAMP_TZ' needs to be a string
Any idea what could be going wrong here?
Thanks
SELECT
TO_VARCHAR(stg.$10),
TO_VARCHAR(stg.$45),
TO_NUMBER(stg.$1,20),
TO_NUMBER(stg.$18,20),
TO_VARCHAR(stg.$8),
TO_VARCHAR(stg.$42),
TO_NUMBER(stg.$19,20),
TO_VARCHAR(stg.$11),
TO_VARCHAR(stg.$16),
TO_VARCHAR(stg.$49),
TO_TIMESTAMP_TZ(stg.$47::STRING,'21'),
TO_TIMESTAMP_TZ(stg.$50::STRING,10),
TO_VARCHAR(stg.$48),
TO_NUMBER(stg.$36,19,6),
TO_NUMBER(stg.$27,19,6),TO_VARCHAR(stg.$12),
TO_TIMESTAMP_TZ(stg.$13::STRING,10),
TO_TIMESTAMP_TZ(stg.$5::STRING,10),
TO_NUMBER(stg.$22,20),
TO_NUMBER(stg.$21,19,6),
TO_NUMBER(stg.$20,19,6),
TO_TIMESTAMP_TZ(stg.$2::STRING,10),
TO_NUMBER(stg.$39,19,6),TO_VARCHAR(stg.$35),
TO_VARCHAR(stg.$4),
TO_NUMBER(stg.$40,19,6),
TO_NUMBER(stg.$32,19,6),
TO_NUMBER(stg.$33,19,6),
TO_VARCHAR(stg.$34),
TO_VARCHAR(stg.$37),
TO_VARCHAR(stg.$38),
TO_VARCHAR(stg.$17),
TO_VARCHAR(stg.$23),
TO_NUMBER(stg.$14,19,6),
TO_NUMBER(stg.$28,19,6),
TO_NUMBER(stg.$29,19,6),
TO_NUMBER(stg.$41,6,2),
TO_VARCHAR(stg.$31),
TO_NUMBER(stg.$30,19,6),
TO_VARCHAR(stg.$24),
TO_VARCHAR(stg.$25),
TO_NUMBER(stg.$26,19,6),
TO_VARCHAR(stg.$9),
TO_TIMESTAMP_TZ(stg.$3::STRING,10),
TO_VARCHAR(stg.$15),
TO_VARCHAR(stg.$44),
TO_VARCHAR(stg.$43),
TO_VARCHAR(stg.$53),
TO_TIMESTAMP_TZ(stg.$51::STRING,10),
TO_TIMESTAMP_TZ(stg.$50::STRING,10),
TO_VARCHAR(stg.$52),
TO_TIMESTAMP_TZ(stg.$7::STRING,10),
TO_TIMESTAMP_TZ(stg.$6::STRING,10),
'T_RPDB_POLICY_1_0_0',
TO_TIMESTAMP_TZ(CURRENT_TIMESTAMP::STRING)
FROM '#INTERNAL_POLICY_STAGE/T_RPDB_POLICY.CSV.gz' (file_format => '"JVCO"."STAGING".CSV') stg;
Try
select to_timestamp_tz(CURRENT_TIMESTAMP::string)
Second argument is format(varchar type) and you are passing number.
select to_timestamp_tz('04/05/2013 01:02:03', 'mm/dd/yyyy hh24:mi:ss');
https://docs.snowflake.com/en/sql-reference/functions/to_timestamp.html
I'm new to Julia and currently trying to run the following code:
Using DelimitedFiles
M=readdlm(data)
ts,A=M[:,1],M[:,2:end]
(nsweeps,N)=size(A)
dx=0.01;
x=[minimum(collect(A)):dx:maximum(collect(A))];
bx=[x-dx/2,x[end]+dx/2];
But, when I try to run the last line of code, it gives me the following error:
MethodError: no method
matching(::Array{StepRangeLen{Float64,Base.TwicePrecision
{Float64},Base.TwicePrecision{Float64}},1}, ::Float64)
Closest candidates are:
-(!Matched::BigFloat, ::Union{Float16, Float32, Float64}) at
mpfr.jl:437
-(!Matched::Complex{Bool}, ::Real) at complex.jl:307
-(!Matched::Missing, ::Number) at missing.jl:115
Can you please help me? Also, the data I'm using it's
30×6 Array{Float64,2}
UPDATE here's the whole function I'm trying to run is the following:
function mymain(filename,nsamples)
start_time=time()
M=readdlm(filename)
ts,A=M[:,1],M[:,2:end]
(nsweeps,N)=size(A)
dx=0.01;
x=[minimum(collect(A)):dx:maximum(collect(A))];
bx=[x-dx/2,x[end]+dx/2];
(bx,hA)=hist(A[:],bx);
f1=figure()
subplot(2,1,1); plot(ts,A,"-o"); xlabel("Time [ms]"); ylabel("Amps
[mV]");
subplot(2,1,2); plot(x,hA,"-"); xlabel("Amps [mV]");
ylabel("Density");draw()
nparams=8
Sx=Array(ASCIIString,1,nparams)
Rx=zeros(2,nparams)
nx=zeros(Int,1,nparams)
Sx[1,1]="p"; Rx[1:2,1]=[0.02,0.98]; nx[1]=49
Sx[1,2]="n"; Rx[1:2,2]=[1,20]; nx[2]=20
Sx[1,3]="tD"; Rx[1:2,3]=[50,200]; nx[3]=46
Sx[1,4]="a"; Rx[1:2,4]=[0.05,0.5]; nx[4]=46
Sx[1,5]="siga"; Rx[1:2,5]=[0.01,0.2]; nx[5]=39
Sx[1,6]="sigb"; Rx[1:2,6]=[0.01,0.1]; nx[6]=19
Sx[1,7]="tauf"; Rx[1:2,7]=[50,200]; nx[7]=46
Sx[1,8]="u1"; Rx[1:2,8]=Rx[1:2,1]; nx[8]=nx[1]
x=zeros(maximum(nx),nparams)
p=zeros(maximum(nx),nparams)
dx=zeros(1,nparams)
for j=1:nparams
x[1:nx[j],j]=linspace(Rx[1,j],Rx[2,j],nx[j])'
dx[j]=x[2,j]-x[1,j]
end
S=zeros(Int,nsamples,nparams)
sold=zeros(Int,1,nparams)
for j=1:nparams
sold[j]=rand(1:nx[j])
end
while x[sold[4],4]<=x[sold[5],5]
sold[4]=rand(1:nx[4])
sold[5]=rand(1:nx[5])
end
while x[sold[8],8]<=x[sold[1],1]
sold[1]=rand(1:nx[1])
sold[8]=rand(1:nx[8])
end
xold=zeros(1,nparams)
xnew=zeros(1,nparams)
for j=1:nparams
xold[j]=x[sold[j],j]
end
llold=myloglikelihood(xold,ts,A)
for k=1:nsamples
snew=sold+rand(-1:1,1,nparams)
if all(ones(1,nparams).<=snew.<=nx)
allowed2=x[snew[4],4]>x[snew[5],5]
allowed3=x[snew[8],8]>x[snew[1],1]
if allowed2&allowed3
for j=1:nparams
xnew[j]=x[snew[j],j]
end
llnew=myloglikelihood(xnew,ts,A)
if rand()<exp(llnew-llold)
sold,llold=snew,llnew
end
end
end
S[k,:]=sold
end
for k=1:nsamples
for j=1:nparams
p[S[k,j],j]+=1/(nsamples*dx[j])
end
end
f2=figure()
for j=1:nparams
subplot(2,4,j)
plot(x[1:nx[j],j],p[1:nx[j],j]);
xlabel(Sx[j])
end
diff_time=time()-start_time;
println("Total runtime
",round(diff_time,3),"s=",round(diff_time/60,1),"mins." );
return S
end
This goes in line with some other functions, but as you can see, this is the main function, so I really can't move forward without first runnning this one.
It isn't clear what outcome you are hoping for here. So I'll just give some pointers that hopefully help.
First, in this line:
x=[minimum(collect(A)):dx:maximum(collect(A))];
the calls to collect are redundant. Also, I suspect you are trying to construct a StepRangeLen, but by putting it in [] you actually are getting a Vector{StepRangeLen}. I think what you want in this line is actually this:
x=minimum(A):dx:maximum(A);
Second, in this line:
bx=[x-dx/2,x[end]+dx/2];
note that dx/2 is a Float64 while x is a StepRangeLen. This is important because the latter is a collection so if you want to perform this operation element-wise across the collection you need to broadcast, that is, x .- dx/2. Note, I suspect you may not be on the latest version of Julia, because when I run this the error message actually tells me explicitly I need to broadcast. Anyway, in contrast, x[end]+dx/2 is fine and does not need to be broadcast because x[end] is Float64. So I think you want:
bx=[x .- dx/2, x[end] + dx/2];
Having said that, it isn't clear to me why you want this bx, which is why I said at the start I'm not sure what outcome you were hoping for.
I am trying to build let expression for solr stream but it gives error saying
Caused by: java.io.IOException: Invalid stream expression col(samples,score) - function 'col' is unknown (not mapped to a valid TupleStream)
StreamFactory = new StreamFactory().withDefaultZkHost(zookeeper)
.withFunctionName("search", CloudSolrStream.class)
.withFunctionName("select", SelectStream.class)
.withFunctionName("merge", MergeStream.class)
.withFunctionName("sort", SortStream.class)
.withFunctionName("tuple", TupStream.class)
.withFunctionName("rollup", RollupStream.class)
.withFunctionName("hashJoin", HashJoinStream.class)
.withFunctionName("count", CountMetric.class)
.withFunctionName("facet", FacetStream.class)
.withFunctionName("sum", SumMetric.class)
.withFunctionName("unique", UniqueStream.class)
.withFunctionName("significantTerms", SignificantTermsStream.class)
.withFunctionName("stats", StatsStream.class)
.withFunctionName("innerJoin", InnerJoinStream.class)
.withFunctionName("issnMerge", IssnMergeStream.class)
.withFunctionName("intersect", IntersectStream.class)
.withFunctionName("boostByEra", BoostBooksByEraExpression.class)
.withFunctionName("determineRRec", DetermineRepresentativeRecord.class)
.withFunctionName("plist", ParallelListStream.class)
.withFunctionName("let", LetStream.class);
My expression is as below:
let(samples=search(wc_art,qt="/select",q="al:next AND al:generation",fq="_delete:false",fq="_namespace:default",fl="score,numdocs(),id",rows=10,fq="{!lucene q.op=OR}pa:(medline)",defType=edismax,q.op=AND,sort="score desc"),responses=col(samples,score),summary=describe(responses))
The col function was added in Solr 7, so if your Solr installation is older than that the function won't be available. Upgrade to a more recent version.
I am trying to use the application oecosimu in Vegan package.
library(sna)
library(permute)
library(lattice)
library(vegan)
library(bipartite)
bio<-read.csv("/home/vicar66/Raw_data/Jan12/98percents_April_16/otu_table/Chapter1/no_bloom_bio_data_L3.txt")
rownames(bio)<-bio[,1]
bio[,1]<-NULL
bio_m<-as.matrix(bio)
a<-oecosimu(bio_m,bipartite::C.score,"swap")
but I keep having this error message:
Attaching package: 'bipartite'
The following object is masked from 'package:vegan':
nullmodel
Error in rowSums(x) : 'x' must be an array of at least two dimensions
Calls: oecosimu -> nullmodel -> rowSums
Execution halted
demo data:
Ciliophora Dinoflagellates MALVs Choanoflagellida
DNAHIN5m 0.062469804 0.826323018 0.031084701 0.000323747
DNAHIN35m 0.045216826 0.595750636 0.187010719 0.000917053
DNAHIN150m 0.018434224 0.204865296 0.531016032 0.017009618
DNAHIN240m 0.016211333 0.889640227 0.04191846 0.03087407
**first column first row is empty. First row are rownames
Anyone have encountered this problem yet?
Thanks!
We have trouble with the solr Spatial queries some polygon queries just don´t work, we don´t know why. If you have a field of type solr.SpatialRecursivePrefixTreeFieldType
<!-- fieldType to store a location in the new format of Solr Version 4 -->
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
distErrPct="0.025"
maxDistErr="0.000009"
units="degrees"/>
and make a Query on the field with the following filter-query:
fq=fieldname:"IsWithin(POLYGON((10.949260925162957 50.687958071020525, 10.963822885556231 50.68239399969996, 10.964563833856873 50.68427156144517, 10.96703711832961 50.68658303201778, 10.971062408240995 50.68545999328907, 10.973908368601569 50.68537639297307, 10.977245419297885 50.683455151899885, 10.987904529571237 50.68294282194555, 10.991325387038 50.67963515860285, 10.994120583977482 50.67953326334638, 10.99521208549133 50.6789077661364, 11.001058877152785 50.678738633565445, 11.001548604905265 50.67818764634437, 11.001856364353715 50.677835397891904, 11.00558285688531 50.67803512409588, 11.0081512617408 50.67851875352985, 11.006105355255587 50.6765931916203, 11.007343317894337 50.675840952835756, 11.00508803742539 50.67549090681522, 11.003645117340879 50.67430948629124, 11.005941540214492 50.67061936637505, 11.006219536083469 50.67014126679768, 11.001299804762878 50.67083752214686, 11.001290248726937 50.66994678133127, 11.001266698032165 50.66775142007361, 10.994310850026004 50.6686811276132, 10.99361484218618 50.66578680941357, 10.995238751284973 50.66272061868265, 10.991757060004929 50.66144878694344, 10.98564228736983 50.656057950464636, 10.972933054968484 50.65619159367484, 10.966916033500995 50.654632430958905, 10.96636369345939 50.64608677373722, 10.962270574823638 50.645743297249716, 10.960072993917557 50.646759811319946, 10.959183606001607 50.64697929266767, 10.953790500283061 50.64683862129752, 10.950513303019612 50.645987649473184, 10.94433093410472 50.64467990104971, 10.944139287321171 50.64387083905674, 10.938406478377123 50.64367676951595, 10.936564706423367 50.64344079815689, 10.935796834794198 50.64303879575035, 10.934872743703187 50.64257439164639, 10.93427419432756 50.64211775581536, 10.933160359264956 50.641024208099076, 10.930818579187104 50.638720535539385, 10.930731698801951 50.63850491325951, 10.930573248685782 50.63819957997579, 10.930514584183914 50.63797485471301, 10.930483968228721 50.63772303174961, 10.930509448204717 50.637417013430884, 10.930559495850991 50.63670600493446, 10.930609790537858 50.636021988733695, 10.93062319254464 50.635940959080145, 10.930918118427178 50.63346819840206, 10.929554613720612 50.63173063011565, 10.928233196678372 50.63073800085285, 10.927700297053727 50.630337678088054, 10.928523643504606 50.62943775333723, 10.92872309691077 50.62921974159881, 10.928265672945901 50.62878750906588, 10.927639188094208 50.628566694106404, 10.926255509527108 50.62951454513081, 10.92251019209241 50.62758567817641, 10.922638213078281 50.62684244467462, 10.920936313471174 50.62702387937161, 10.92057977557142 50.62670125843647, 10.920152680177981 50.62639688838215, 10.918545217179695 50.62538597524043, 10.917792182353438 50.62501079438114, 10.911101933460412 50.62182259063344, 10.910534063522139 50.62158167018572, 10.910220857740773 50.62134884112989, 10.909963518297891 50.62103483348087, 10.907487776980194 50.61609483529123, 10.907185632204035 50.61550204988257, 10.907056244585032 50.61525956691028, 10.906628481384871 50.61485617486339, 10.895152937829938 50.610730036478415, 10.896242368859731 50.61247186463941, 10.896470601420656 50.61270502268978, 10.89663156493272 50.61334330885494, 10.896634921258965 50.613739197264394, 10.896609690263567 50.61409919288572, 10.896528427773802 50.6145223648505, 10.896432183751319 50.61484661316548, 10.896045213866357 50.61590967155394, 10.89592075624567 50.616243013829695, 10.895851037118929 50.616360223083014, 10.89585240754103 50.616522177442015, 10.896067734815928 50.61689934415773, 10.896183689961353 50.61723186255236, 10.896260192619177 50.6179154274055, 10.896263393697025 50.61829332089865, 10.896237700111788 50.618599331654885, 10.896016371366 50.619184942393495, 10.895837465600053 50.61977040740378, 10.895659620811532 50.62048183664009, 10.89552077688743 50.62078823450612, 10.89543827592144 50.62106744627099, 10.89541440081784 50.62158939599526, 10.895417747434317 50.621985284440285, 10.895419953189784 50.62224621091522, 10.895535536566323 50.62253374263596, 10.895650816938675 50.62278528438301, 10.895907993767457 50.623090326427935, 10.89702205813367 50.62436418220272, 10.897394394709464 50.624902766276065, 10.897581866399983 50.62532501473681, 10.897627895017118 50.625747749544246, 10.897615356639628 50.62593674492591, 10.89758943824656 50.626215763590146, 10.897451201612462 50.62659414347733, 10.897157596764943 50.62700005028155, 10.896204881347344 50.62808304669058, 10.895980612498475 50.62832675371888, 10.895770334536648 50.628552416954996, 10.89550476578125 50.62893123030415, 10.895365743634875 50.629219633049715, 10.895298437344238 50.62962476083249, 10.895301175148079 50.629948669556875, 10.895818784010213 50.63130826952094, 10.896231728685844 50.63233529670317, 10.896329308521908 50.63324913379934, 10.896471808085538 50.634162815888054, 10.896387784931676 50.63484873155491, 10.895853362204946 50.63539335124816, 10.895409731359035 50.636051929955904, 10.894831087434723 50.63668239938101, 10.89384501665182 50.63694287338006, 10.89321877746772 50.63725925036571, 10.89295453697872 50.63788864146319, 10.892601884032173 50.638689738782595, 10.892158656701907 50.639405438006676, 10.89142586330462 50.64018326820631, 10.891249605392286 50.64110163233304, 10.891209792351503 50.64141668728772, 10.891144841137194 50.64210973155851, 10.891149583241901 50.64267657195861, 10.891137616301116 50.64293754635428, 10.891225677492942 50.64331515274541, 10.891298535787737 50.64356684242054, 10.891485499888212 50.643926118463014, 10.891671788482595 50.644204417006435, 10.891786196727102 50.6443479929879, 10.892544546820737 50.64534416832987, 10.893174209281039 50.6461788173941, 10.89351799460153 50.646672522785806, 10.893705215492075 50.64705878762453, 10.894882157433013 50.650689855006604, 10.89496919918023 50.65094149403119, 10.894994089923097 50.65100770424872, 10.894997994355002 50.65101034884133, 10.89526819691057 50.651193363455, 10.896169293366368 50.651475958949085, 10.897116063005601 50.65184409397104, 10.897793725703924 50.652270282727144, 10.89865162997703 50.652752981995214, 10.89955326530773 50.65309268499627, 10.900497891510984 50.65320368900172, 10.901396850557482 50.65322914045231, 10.902342714743133 50.653482964947386, 10.903109828708763 50.6538516751205, 10.903877201611301 50.65424894803099, 10.904724676108554 50.65470480867649, 10.905207763672205 50.654919062782206, 10.905577393216744 50.65510671959086, 10.90571963130609 50.65518720031583, 10.906032572458294 50.65536605678589, 10.906360295427413 50.65561684232866, 10.908203641750418 50.65761684566244, 10.908460620376147 50.65786787497885, 10.908759750304794 50.65808276386111, 10.90914317979857 50.65822537198042, 10.9096827055135 50.65841241475139, 10.910052143839932 50.65857306489363, 10.910322344422498 50.65871607046202, 10.910593099948478 50.658922057564695, 10.911461366599966 50.65946783407124, 10.913411561596815 50.66070256810259, 10.913667868428533 50.6608726087896, 10.914080443553491 50.66110507379473, 10.914449918280287 50.66126570988579, 10.91479092498766 50.661408451414985, 10.915358821001677 50.661595366186866, 10.915898410493476 50.66178237995819, 10.916565404597831 50.66196893251853, 10.918197483579679 50.66243092630801, 10.918680067924226 50.66257314454925, 10.918978548993268 50.662707029974975, 10.919547769889176 50.6630378833151, 10.9202031483812 50.66350338704778, 10.923424641120155 50.66438241716476, 10.92520056514587 50.66507772742578, 10.928643442713414 50.66691855773872, 10.931248634299681 50.668474484061434, 10.931482632159552 50.66928340878597, 10.93237915166098 50.66977493796525, 10.934586015828625 50.671098336511534, 10.935184017704177 50.671455998806955, 10.935810765428391 50.67185853851997, 10.9360388137638 50.67201963882665, 10.936252537002147 50.67216279720219, 10.93640887044287 50.6722251919134, 10.93797214347626 50.672840129973565, 10.93838469191684 50.6730455159511, 10.938683803183944 50.673233335093705, 10.938870320684071 50.6734935625849, 10.938944158876946 50.67381720153802, 10.938904808606113 50.67415026758631, 10.938906837075631 50.674366205911554, 10.93906453424018 50.67457255591528, 10.939249959577586 50.67471581619838, 10.940034490045216 50.675324682544115, 10.940291821850632 50.67558463848537, 10.940622161521706 50.676078257435236, 10.94075248591146 50.67638368467924, 10.940783437202692 50.67666249709234, 10.943222552787118 50.678524713221, 10.944035691536161 50.67915143877554, 10.944773250404303 50.679274574957105, 10.945325950398017 50.67931743817247, 10.945708292314846 50.67931596622919, 10.946768093608876 50.68189437491155, 10.94729335869263 50.68482498983269, 10.947961248322919 50.68588856337425, 10.949260925162957 50.687958071020525)))"
(even if the index is empty) solr hangs and loads forever without error logging or showing results. This happens to a lot of queries / polygons that we try to query. What are we doing wrong, or is the polygon search not yet usable in solr 4.5?
I found the answer here: http://wiki.apache.org/solr/SolrTomcat#Enabling_Longer_Query_Requests
Enabling Longer Query Requests
If you try to submit too long a GET query to Solr, then Tomcat will reject your HTTP request on the grounds that the HTTP header is too large; symptoms may include an HTTP 400 Bad Request error or (if you execute the query in a web browser) a blank browser window.
If you need to enable longer queries, you can set the maxHttpHeaderSize attribute on the HTTP Connector element in your server.xml file. The default value is 4K. (See http://tomcat.apache.org/tomcat-5.5-doc/config/http.html)
The polygons where just too long to submit to solr via GET-request. We changed the Tomcat settings now everything works fine.