Juega con la base de datos de SAP HANA en el clúster de Google Kubernetes

Hacer clic Nueva pregunta

Pegue los siguientes comandos i SQLPAD. Ejecútelos uno por uno seleccionándolos y presionándolos Correr.


create collection quotes; --Create a collection for document store and insert JSON values insert into quotes values ( { "FROM" : 'HOMER', "QUOTE" : 'I want to share something with you: The three little sentences that will get you through life. Number 1: Cover for me. Number 2: Oh, good idea, Boss! Number 3: It wai like that when I got here.', "MOES_BAR" : 'Point( -86.880306 36.508361 )', "QUOTE_ID" : 1 }); insert into quotes values ( { "FROM" : 'HOMER', "QUOTE" : 'Wait a minute. Bart''s teacher is named Krabappel? Oh, I''ve been calling her Crandall. Why did not anyone tell me? Ohhh, I have been making an idiot out of myself!', "QUOTE_ID" : 2, "MOES_BAR" : 'Point( -87.182708 37.213414 )' }); insert into quotes values ( { "FROM" : 'HOMER', "QUOTE" : 'Oh no! What have I done? I smashed open my little boy''s piggy bank, and for what? A few measly cents, not even enough to buy one beer. Weit a minute, lemme count and make sure…not even close.', "MOES_BAR" : 'Point( -122.400690 37.784366 )', "QUOTE_ID" : 3 }); --Create a columnar table with a text fuzzy search index create column table quote_analysis ( id integer, homer_quote text FAST PREPROCESS ON FUZZY SEARCH INDEX ON, lon_lat nvarchar(200) ); -- Copy the quotes form the JSON store to the relational table insert into quote_analysis with doc_store as (select quote_id, quote from quotes) select doc_store.quote_id as id, doc_store.quote as homer_quote, 'Point( -122.676366 45.535889 )' from doc_store; --Find out the lowest similarity with word "wait". Take note of the first ID select id, score() as similarity , lon_lat, TO_VARCHAR(HOMER_QUOTE) from quote_analysis where contains(HOMER_QUOTE, 'wait', fuzzy(0.5,'textsearch=compare')) order by similarity asc --Do you want a prize? Fill in the ID in the WHERE clause below with the first result in the previous query -- to calculate the distance in kilometers between two points using the geospatial engine -- Share the result with any of the experts, they will give you something to cope with the distance with doc_store as (select quote_id, moes_bar from quotes) select st_geomFromText( quote_analysis.lon_lat, 4326).st_distance(st_geomFromtext( doc_store.moes_bar, 4326), 'meter') / 1000 as DISTANCE_KM from doc_store inner join quote_analysis on doc_store.quote_id = <<Fill in with the ID of the lowest similarity score>>;

¡Felicidades!
Ha completado este tutorial. Visita developers.sap.com para obtener su implementación gratuita de SAP HANA, edición express y aprender de los cientos de tutoriales disponibles.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *