private static async Task FillRoutingInfo(PreparedStatement ps, ICluster cluster) { var column = ps.Metadata.Columns.FirstOrDefault(); if (column?.Keyspace == null) { // The prepared statement does not contain parameters return; } if (ps.Metadata.PartitionKeys != null) { // The routing indexes where parsed in the prepared response if (ps.Metadata.PartitionKeys.Length == 0) { // zero-length partition keys means that none of the parameters are partition keys // the partition key is hard-coded. return; } ps.RoutingIndexes = ps.Metadata.PartitionKeys; return; } try { const string msgRoutingNotSet = "Routing information could not be set for query \"{0}\""; var table = await cluster.Metadata.GetTableAsync(column.Keyspace, column.Table).ConfigureAwait(false); if (table == null) { Logger.Info(msgRoutingNotSet, ps.Cql); return; } var routingSet = ps.SetPartitionKeys(table.PartitionKeys); if (!routingSet) { Logger.Info(msgRoutingNotSet, ps.Cql); } } catch (Exception ex) { Logger.Error("There was an error while trying to retrieve table metadata for {0}.{1}. {2}", column.Keyspace, column.Table, ex.InnerException); } }