Member since
02-23-2016
51
Posts
96
Kudos Received
4
Solutions
My Accepted Solutions
Title | Views | Posted |
---|---|---|
1427 | 05-25-2016 04:42 PM | |
2538 | 05-16-2016 01:09 PM | |
960 | 04-27-2016 05:40 PM | |
3996 | 02-26-2016 02:14 PM |
07-09-2016
01:29 AM
1 Kudo
Repo Description This zeppelin dashboard demonstrates how to map all the data types from HAWQ to HIVE using sqoop. It uses postgress sql to create the HAWQ table and fills in 1 col for every data type. The more significant piece shown here is how to map the data types that differ from HAWQ to HIVE. For exmaple a boolean column in HAWQ exports as t or f but that is not compatible with HIVE. Using postgress and sqoop this converts to TRUE and FALSE which is accepted by HIVE. Repo Info Github Repo URL https://github.com/kirkhas/zeppelin-notebooks/tree/master/HAWQ-Sqoop Github account name kirkhas/zeppelin-notebooks/tree/master Repo name HAWQ-Sqoop
... View more
Labels:
07-06-2016
08:39 PM
3 Kudos
Repo Description Why create yet another VaR example? To demonstrate VaR running on a modern architecture that has no vertical limit. This is a functional, immutable, scaleable interpretation of a basic technique commonly used in finance. zephub link https://www.zeppelinhub.com/viewer/notebooks/aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2tpcmtoYXMvemVwcGVsaW4tbm90ZWJvb2tzL21hc3Rlci9Nb250ZUNhcmxvVmFyL25vdGUuanNvbg Repo Info Github Repo URL https://github.com/kirkhas/zeppelin-notebooks/tree/master/MonteCarloVar Github account name kirkhas/zeppelin-notebooks/tree/master Repo name MonteCarloVar
... View more
07-06-2016
04:24 PM
4 Kudos
Query JSON using Spark
Imagine you are ingesting JSON msgs but each one has different tag names or even a different structure. This is very common because JSON is a flexible nested structure. However we commonly interact with data in a flat table like structure using SQL. The decision becomes to either parse the dynamic data into a physical schema (on write) or apply a schema at runtime (on read). Ultimately the decision will likely be made based on the number of writes vs reads. However there is one major advantage to using Spark to apply schema on read to JSON events, it alleviates the parsing step. Typically you have to hand code all the tags in the JSON msgs and map each one to a schema column. This may require meeting with upstream teams or third parties to get the DDL/xsd or schema definition. It also doesn't protect you from msgs you haven't seen or new tags being added to existing JSON structures. Sparks schema on read handles all of this as well as flattens the structure into a SQL queryable table. In the example below there are 3 different JSON msgs each with different tags and structures. If the goal is to normalize the data for a specific reporting or data science task you may be better off defining a physical schema where items like price and strikePrice are converged to a common column that makes sense in both contexts. However if your goal is to process or serve msgs like a msg bus, or if you find that it is better to query stocks separately from options because the attributes should not be interpreted and you do not want to become the author of the data you are processing then this could be an ideal approach. (A non-authoritative, low maintenance approach that is queryable) {"tradeId":"123", "assetClass":"stock", "transType":"buy", "price":"22.34",
"stockAttributes":{
"5avg":"20.12","52weekHi":"27.56"
}
}
{"tradeId":"456", "assetClass":"future", "transType":"sell", "strikePrice":"40.00",
"contractType": "forward",
"account":{
"city":"Columbus","state":"Ohio", "zip":"21000"
}
}
{"tradeId":"789", "assetClass":"option", "transType":"buy", "strikePrice":"35.75",
"account":{
"accountType":"retail","city":"Columbus","state":"Ohio"
}
}
1.0 The below image shows the 3 different JSON msgs (stock,option,future) with different attributes and structures.
2.0 Here you can query all of the data or any segment of the data using SQL.
Full code on zephub - code link
Pros: Data tags and structure are always in sync with provider No data loss No parsing layer (code effort), faster time to market No authoring, naming or defining columns Cons: SQL reads will be slower than a physically flattened and written table Deserialization cost and can't benefit from modern day columnar operations Compression - "don't use JSON" video from summit https://www.youtube.com/watch?v=tB28rPTvRiI&feature=youtu.be&t=20m3s
... View more
Labels:
06-10-2016
10:45 PM
16 Kudos
Predict Stock Portfolio Gains Using Monte Carlo Why?
Why create yet another VaR example? To demonstrate VaR running on a modern architecture that has no vertical limit. This is a functional, immutable, scaleable interpretation of a basic technique commonly used in finance. Code Available here and on github. https://github.com/kirkhas/zeppelin-notebooks/
link to Vlad's article for history of Monte Carlo and VaR - https://community.hortonworks.com/articles/36321/predicting-stock-portfolio-losses-using-monte-carl.html Some modifications from original posting include: scala calling Yahoo API directly, alleviating the need for shell scripting and adding interopability between variables. All data loaded dynamically in memory, removing the need to store files (which inherently adds manual customizations to a generic process). Code all in Zeppelin for readability. Visualizations in Zeppelin. Inputs built in using Zep forms so the user can interact with the model. Percentiles not only on what's at risk each day but also on final portfolio value.
Figure 1.0 shows the risk you would take on per each day holding these 3 stocks.
Figure 2.0 shows what a reasonable projected outcome might be after holding this position for 100 days.
Checkout the code it has a lot more visuals. Key takeaway: "You should have purchased shares of HDP in mid Feb 2016!"
Code View
https://www.zeppelinhub.com/viewer/notebooks/aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2tpcmtoYXMvemVwcGVsaW4tbm90ZWJvb2tzL21hc3Rlci9Nb250ZUNhcmxvVmFyL25vdGUuanNvbg
Report View
https://www.zeppelinhub.com/viewer/notebooks/aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2tpcmtoYXMvemVwcGVsaW4tbm90ZWJvb2tzL21hc3Rlci9Nb250ZUNhcmxvVmFyL1JlcG9ydFZpZXcvbm90ZS5qc29u
... View more
05-26-2016
07:41 PM
1 Kudo
Thanks all @Artem Ervits @Tom McCuch for the comments. I did get it resolved by passing all the S3 jars properly on the classpath. The articles included in your threads helped.
... View more
05-26-2016
01:02 PM
Unable to execute the queries on S3 data using SPARK and PYSPARK. It is throwing below error. : java.lang.RuntimeException: java.lang.ClassNotFoundException: Class org.apache.hadoop.fs.s3a.S3AFileSystem not found at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2195) at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2638) at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2651) …. …. Caused by: java.lang.ClassNotFoundException: Class org.apache.hadoop.fs.s3a.S3AFileSystem not found at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:2101) at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2193) we have tried it by adding below parameters but no luck. Parameter name: fs.s3a.impl Parameter value: org.apache.hadoop.fs.s3a.S3AFileSystem Added this paramter in hdfs.site.xml, core-site.xml, hive-site.xml and also added the aws jar files in mapred-site.xml (added to classpath)files.
... View more
Labels:
- Labels:
-
Apache Spark
05-25-2016
04:42 PM
The final resolution was this: Ambari was only showing a "SERVER ERROR" msg on final step with no stack trace. After reading the log I saw there was a primary key constraint on the table "clusterservices". remove this row from table. Then re-install via ambari and it was successful. My hunch is that we got into this state by first trying to remove or edit a service that was already running.
... View more
05-25-2016
03:15 PM
@Artem Ervits looks like you were right, once I got a hold of the logs looks like they did not stop the service first. 20 May 2016 11:05:21,732 INFO [ambari-heartbeat-processor-0] HeartbeatProcessor:603 - State of service component NODEMANAGER of service YARN of cluster HDPPOC2 has changed from UNKNOWN to STARTED at host ip-10-228-210-131 according to STATUS_COMMAND report
20 May 2016 11:05:33,535 ERROR [qtp-ambari-client-41] AbstractResourceProvider:338 - Caught AmbariException when modifying a resource
org.apache.ambari.server.AmbariException: Cannot remove ZEPPELIN. Desired state STARTED is not removable. Service must be stopped or disabled.
at org.apache.ambari.server.controller.internal.ServiceResourceProvider.deleteServices(ServiceResourceProvider.java:869)
at org.apache.ambari.server.controller.internal.ServiceResourceProvider$3.invoke(ServiceResourceProvider.java:247)
at org.apache.ambari.server.controller.internal.ServiceResourceProvider$3.invoke(ServiceResourceProvider.java:244)
at org.apache.ambari.server.controller.internal.AbstractResourceProvider.invokeWithRetry(AbstractResourceProvider.java:450) 20 May 2016 11:06:52,501 ERROR [qtp-ambari-client-42] AmbariJpaLocalTxnInterceptor:180 - [DETAILED ERROR] Rollback reason:
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.2.v20151217-774c696): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: update or delete on table "servicecomponentdesiredstate" violates foreign key constraint "hstcmpnntdesiredstatecmpnntnme" on table "hostcomponentdesiredstate"
Detail: Key (component_name,cluster_id,service_name)=(ZEPPELIN_MASTER,2,ZEPPELIN) is still referenced from table "hostcomponentdesiredstate".
Error Code: 0
Call: DELETE FROM servicecomponentdesiredstate WHERE (((cluster_id = ?) AND (component_name = ?)) AND (service_name = ?))
bind => [3 parameters bound]
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
... View more
05-23-2016
03:35 PM
Removed all components related to Zeppelin from Ambari, and tried to reinstall again but everytime its failing with the error "Server error." used this cmd to remove the service. is there something else that required cleaning up? curl -u admin:admin -X DELETE -H 'X-Requested-By:1' http://10.228.210.175:80/api/v1/clusters/HDPPOC2/services/ZEPPELIN
... View more
Labels:
- Labels:
-
Apache Ambari
-
Apache Zeppelin
05-16-2016
01:09 PM
5 Kudos
Results from using sqoop to move data from HAWQ to HIVE. @Artem Ervits and @cstanca HAWQ Hive Result int int worked text string worked date string write=string, onRead date operations work timestamp string write=string, onRead ts operations work bit boolean conversion does not work decimal double mostly works, precision loss > 9
double precision double works real double works interval Breaks! sqoop mapping error bit varying Breaks! sqoop mapping error time string write=string, onRead time operations work char string write=string, onRead you need wildcard expression, recommend trimming char varying string write=string, onRead holds whitespace, recommend trimming varchar string works boolean boolean works numeric double works %sh
sqoop import --username zeppelin --password zeppelin --connect jdbc:postgresql://jdbcurl --query 'SELECT id,name,join_date,age,a,b,i FROM kirk WHERE $CONDITIONS' -m 1 --target-dir /user/zeppelin/kirk/t6 --map-column-java a=String,i=String,b=String -- select *
select * from kirk ;
-- int check between inclusive
select age from kirk where age between 25 and 27;
-- decimal check
select dec from kirk where dec > 33.32;
-- string like and wildcard
select address from kirk where address like '%Rich%';
-- date is a string but operates like date
select join_date from kirk where join_date between '2007-12-13' and '2007-12-15';
-- timestamp, works string on write but operates like TS
select ts from kirk where ts > '2016-02-22 08:01:22'
-- BIT NOT CORRECT
select a from kirk where a =false or a = 1
-- character varying, without white space matches
select cv from kirk where cv = 'sdfsadf';
-- character varying, with white space
select cv from kirk where cv = 'white space'; -- not matching
select cv from kirk where cv = 'white space '; -- matching
-- character, doesn't match unless wildcard
select c from kirk where c like 'we%';
-- boolean, both true/false and 1/0 are converted properly
select id, isactive from kirk where isactive = true or isactive = 0
... View more