@@ -53,6 +53,8 @@ pub struct Keyspace {
5353 /// Empty HashMap may as well mean that the client disabled schema fetching in SessionConfig
5454 pub tables : HashMap < String , Table > ,
5555 /// Empty HashMap may as well mean that the client disabled schema fetching in SessionConfig
56+ pub views : HashMap < String , Table > ,
57+ /// Empty HashMap may as well mean that the client disabled schema fetching in SessionConfig
5658 pub user_defined_types : HashMap < String , Vec < ( String , CqlType ) > > ,
5759}
5860
@@ -460,13 +462,22 @@ async fn query_keyspaces(
460462 ) ) ?;
461463
462464 let mut result = HashMap :: with_capacity ( rows. len ( ) ) ;
463- let ( mut all_tables, mut all_user_defined_types) = if fetch_schema {
465+ let ( mut all_tables, mut all_views , mut all_user_defined_types) = if fetch_schema {
464466 (
465- query_tables ( conn) . await ?,
467+ query_tables (
468+ conn,
469+ "SELECT keyspace_name, table_name FROM system_schema.tables" ,
470+ )
471+ . await ?,
472+ query_tables (
473+ conn,
474+ "SELECT keyspace_name, view_name FROM system_schema.views" ,
475+ )
476+ . await ?,
466477 query_user_defined_types ( conn) . await ?,
467478 )
468479 } else {
469- ( HashMap :: new ( ) , HashMap :: new ( ) )
480+ ( HashMap :: new ( ) , HashMap :: new ( ) , HashMap :: new ( ) )
470481 } ;
471482
472483 for row in rows. into_typed :: < ( String , HashMap < String , String > ) > ( ) {
@@ -476,6 +487,7 @@ async fn query_keyspaces(
476487
477488 let strategy: Strategy = strategy_from_string_map ( strategy_map) ?;
478489 let tables = all_tables. remove ( & keyspace_name) . unwrap_or_default ( ) ;
490+ let views = all_views. remove ( & keyspace_name) . unwrap_or_default ( ) ;
479491 let user_defined_types = all_user_defined_types
480492 . remove ( & keyspace_name)
481493 . unwrap_or_default ( ) ;
@@ -485,6 +497,7 @@ async fn query_keyspaces(
485497 Keyspace {
486498 strategy,
487499 tables,
500+ views,
488501 user_defined_types,
489502 } ,
490503 ) ;
@@ -533,8 +546,9 @@ async fn query_user_defined_types(
533546
534547async fn query_tables (
535548 conn : & Connection ,
549+ query_str : impl Into < String > ,
536550) -> Result < HashMap < String , HashMap < String , Table > > , QueryError > {
537- let mut tables_query = Query :: new ( "select keyspace_name, table_name from system_schema.tables" ) ;
551+ let mut tables_query = Query :: new ( query_str . into ( ) ) ;
538552 tables_query. set_page_size ( 1024 ) ;
539553
540554 let rows = conn
0 commit comments